Skip to content

Commit

Permalink
ci: Add GH workflow for publishing to npm. (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
junhaoliao authored Dec 27, 2024
1 parent 32b1220 commit beff6ae
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
44 changes: 44 additions & 0 deletions .github/workflows/publish-to-npm.yml
Original file line number Diff line number Diff line change
@@ -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}}"
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down

0 comments on commit beff6ae

Please sign in to comment.