Skip to content

Commit 6ddd3dc

Browse files
committed
Add npm publishing to release workflow
1 parent 01b042b commit 6ddd3dc

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

.github/workflows/release.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,37 @@ jobs:
2222
make_latest: true
2323
env:
2424
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
26+
npm-publish:
27+
needs: github-release
28+
runs-on: ubuntu-latest
29+
steps:
30+
- name: Checkout
31+
uses: actions/checkout@v4
32+
33+
- name: Setup Node.js
34+
uses: actions/setup-node@v4
35+
with:
36+
node-version: '18'
37+
registry-url: 'https://registry.npmjs.org'
38+
39+
- name: Install dependencies
40+
run: npm install
41+
42+
- name: Build package
43+
run: npm run build
44+
45+
- name: Update package version
46+
run: |
47+
TAG_VERSION=${GITHUB_REF#refs/tags/v}
48+
CURRENT_VERSION=$(node -p "require('./package.json').version")
49+
if [ "$TAG_VERSION" != "$CURRENT_VERSION" ]; then
50+
npm version $TAG_VERSION --no-git-tag-version
51+
else
52+
echo "Version already matches tag version $TAG_VERSION, skipping npm version"
53+
fi
54+
55+
- name: Publish to NPM
56+
run: npm publish --access public
57+
env:
58+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)