From beff6ae38b076054bd11e301efdef778051885e1 Mon Sep 17 00:00:00 2001 From: Junhao Liao Date: Thu, 26 Dec 2024 22:04:28 -0500 Subject: [PATCH] ci: Add GH workflow for publishing to npm. (#43) --- .github/workflows/publish-to-npm.yml | 44 ++++++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/publish-to-npm.yml diff --git a/.github/workflows/publish-to-npm.yml b/.github/workflows/publish-to-npm.yml new file mode 100644 index 00000000..fb8f304c --- /dev/null +++ b/.github/workflows/publish-to-npm.yml @@ -0,0 +1,44 @@ +name: "publish-to-npm" + +on: + release: + types: ["created"] + workflow_dispatch: + +permissions: {} + +jobs: + build: + runs-on: "ubuntu-latest" + steps: + - uses: "actions/checkout@v4" + with: + submodules: "recursive" + + - name: "Install task" + run: "npm install --global @go-task/cli" + + - run: "task package" + + - name: "Upload build artifacts" + uses: "actions/upload-artifact@v4" + with: + path: "dist/" + if-no-files-found: "error" + retention-days: 1 + + publish-to-npm: + needs: ["build"] + runs-on: "ubuntu-latest" + steps: + - uses: "actions/checkout@v4" + - uses: "actions/download-artifact@v4" + + - uses: "actions/setup-node@v4" + with: + node-version: 22 + registry-url: "https://registry.npmjs.org/" + + - run: "npm publish" + env: + NODE_AUTH_TOKEN: "${{secrets.NPM_TOKEN}}" diff --git a/package.json b/package.json index b5618fa1..aaa991c9 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "url": "https://github.com/y-scope/clp-ffi-js/issues" }, "scripts": { - "release": "git diff --exit-code && npm publish" + "release": "git diff --exit-code && task package && npm publish" }, "type": "module", "files": [