{"id":46416,"date":"2025-08-16T08:45:24","date_gmt":"2025-08-16T08:45:24","guid":{"rendered":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/?p=46416"},"modified":"2025-08-16T08:45:24","modified_gmt":"2025-08-16T08:45:24","slug":"publish-npm-with-github-push","status":"publish","type":"post","link":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/publish-npm-with-github-push\/","title":{"rendered":"Publish NPM with GitHub push"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\" id=\"github-yaml-location\">github yaml location<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">.github\/workflows\/publish.yml<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">name: \"publish npm\"\n\non:\n  push:\n    tags:\n      - 'v*'\n\njobs:\n  publish:\n    runs-on: ubuntu-latest\n    steps:\n      - name: checkout\n        uses: actions\/checkout@v2\n      - name: setup node\n        uses: actions\/setup-node@v2\n        with:\n          node-version: 16\n          registry-url: https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/registry.npmjs.org\n      - name: publish\n        run: npm publish --access public\n        env:\n          NODE_AUTH_TOKEN: $<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This will push code to NPM after you craete tag with v Example: v1.0.1<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"npm_auth_token\">NPM_AUTH_TOKEN<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Login under NPM profile and create token<\/li>\n\n\n\n<li>go to the github Repository > Settings > Secrets and Variables > Actions<\/li>\n\n\n\n<li>Under Repository secrets create NPM_AUTH_TOKEN and paste it NPM account<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"esbuildjs\">esbuild.js<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">const esbuild = require(\"esbuild\");\nconst sassPlugin = require(\"esbuild-sass-plugin\").sassPlugin;\n\nasync function build() {\n    try {\n        await esbuild.build({\n            entryPoints: [\"..\/main.js\"],\n            bundle: true,\n            \/\/ minify: true,\n            outfile: \"dist\/main.min.js\",\n            plugins: [sassPlugin()],\n        });\n        console.log(\"Build successful\");\n    } catch (error) {\n        console.error(\"Error during build:\", error);\n    }\n}\n\nbuild();<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"packagejson-example\">package.json example<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">{\n  \"name\": \"fuzzy-area\",\n  \"version\": \"1.0.11\",\n  \"description\": \"simple plain js textarea fuzzy autocomplete with option to defne prefix\",\n  \"main\": \"fuzzy-area.js\",\n  \"directories\": {\n    \"example\": \"example\"\n  },\n  \"scripts\": {\n    \"test\": \"echo \\\"Error: no test specified\\\" &amp;&amp; exit 1\"\n  },\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"git+https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/github.com\/dplugins-opensource\/fuzzy-area.git\"\n  },\n  \"keywords\": [\n    \"plain\",\n    \"javascript\",\n    \"textarea\",\n    \"fuzzy\",\n    \"autocomplete\"\n  ],\n  \"author\": \"DPlugins\",\n  \"license\": \"ISC\",\n  \"bugs\": {\n    \"url\": \"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/github.com\/dplugins-opensource\/fuzzy-area\/issues\"\n  },\n  \"homepage\": \"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/github.com\/dplugins-opensource\/fuzzy-area#readme\"\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>github yaml location This will push code to NPM after you craete tag with v Example: v1.0.1 NPM_AUTH_TOKEN esbuild.js package.json example<\/p>\n","protected":false},"author":1,"featured_media":46500,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"slim_seo":{"title":"Publish NPM with GitHub push - Code DPlugins","description":"github yaml location This will push code to NPM after you craete tag with v Example: v1.0.1 NPM_AUTH_TOKEN esbuild.js package.json example"},"_slim_seo_primary_term_category":0,"_slim_seo_primary_term_post_tag":0,"footnotes":""},"categories":[105],"tags":[110,126,127],"dpc_library":[],"class_list":["post-46416","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-github","tag-npm","tag-publish","tag-script"],"_links":{"self":[{"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/posts\/46416","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/comments?post=46416"}],"version-history":[{"count":0,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/posts\/46416\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/media\/46500"}],"wp:attachment":[{"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/media?parent=46416"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/categories?post=46416"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/tags?post=46416"},{"taxonomy":"dpc_library","embeddable":true,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/dpc_library?post=46416"}],"curies":[{"name":"wp","href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/api.w.org\/{rel}","templated":true}]}}