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": [