Skip to content

Commit a6bda7d

Browse files
authored
Add NPM publish workflow (#10)
* Add NPM publish workflow * Update NPM publish workflow to improve versioning and build process * Refactor workflow to include patch version bump
1 parent 935b7d1 commit a6bda7d

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

.github/workflows/npm-publish.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: "Release New Version"
2+
3+
on:
4+
workflow_dispatch:
5+
6+
permissions:
7+
contents: write
8+
9+
jobs:
10+
publish:
11+
name: "Publish to NPM"
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: "Checkout source code"
16+
uses: actions/checkout@v2
17+
18+
- name: "Set up Node.js"
19+
uses: actions/setup-node@v3
20+
with:
21+
node-version: 22.x
22+
registry-url: "https://registry.npmjs.org/"
23+
24+
- name: "Install dependencies"
25+
run: npm ci
26+
27+
- name: "Build package"
28+
run: npm run build
29+
30+
- name: "Set Git user name and email"
31+
run: |
32+
git config --global user.name "github-actions"
33+
git config --global user.email "[email protected]"
34+
35+
- name: "Bump patch version"
36+
run: npm version patch
37+
38+
- name: "Get new version"
39+
id: get_version
40+
run: echo "version=v$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
41+
42+
- name: "Push version bump commit and tag"
43+
run: |
44+
git push origin HEAD
45+
git push origin --tags
46+
47+
- name: "Publish to NPM"
48+
run: npm publish --access public
49+
env:
50+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
51+
52+
- name: "Create GitHub Release"
53+
uses: actions/create-release@v1
54+
with:
55+
tag_name: ${{ steps.get_version.outputs.version }}
56+
release_name: Release ${{ steps.get_version.outputs.version }}
57+
body: |
58+
```
59+
• See CHANGELOG.md for details
60+
• Published by ${{ github.actor }}
61+
```
62+
env:
63+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)