File tree Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Publish to npm
2+
3+ on :
4+ push :
5+ tags :
6+ - " v*"
7+
8+ # Serialize workflow runs. Not strictly necessary, but to be on the safer side.
9+ concurrency : ${{ github.workflow }}-${{ github.ref }}
10+
11+ jobs :
12+ publish :
13+ runs-on : ubuntu-latest
14+
15+ steps :
16+ - name : Checkout repository
17+ uses : actions/checkout@v4
18+
19+ - name : Setup Node.js
20+ uses : actions/setup-node@v4
21+ with :
22+ node-version : 22
23+ registry-url : ' https://registry.npmjs.org/'
24+
25+ - name : Install dependencies
26+ run : npm ci
27+
28+ - name : Build the project
29+ run : npm run build
30+
31+ # Determine if the tag is a release candidate or not
32+ - name : Determine npm tag
33+ id : npm_tag
34+ run : |
35+ if [[ "${{ github.ref_name }}" == *rc* ]]; then
36+ echo "tag=next" >> $GITHUB_ENV
37+ else
38+ echo "tag=latest" >> $GITHUB_ENV
39+
40+ - name : Publish to npm
41+ run : npm publish --access=public --tag ${{ env.tag }}
42+ env :
43+ NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
44+
45+ - name : Create GitHub Release
46+ env :
47+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
48+ run : |
49+ RELEASE_TAG=$(npm view . version)
50+ RELEASE_URL="https://www.npmjs.com/package/$(jq -r .name package.json)/v/$RELEASE_TAG"
51+ gh release create "v$RELEASE_TAG" --title "Release v$RELEASE_TAG" --notes "Published on npm: $RELEASE_URL"
You can’t perform that action at this time.
0 commit comments