Skip to content

Commit a220b6e

Browse files
committed
ci: add release workflow triggered by v*.*.* tags
1 parent 89311dc commit a220b6e

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*'
7+
8+
permissions:
9+
contents: read
10+
id-token: write
11+
12+
jobs:
13+
publish:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: actions/setup-node@v4
18+
with:
19+
node-version: 20
20+
registry-url: 'https://registry.npmjs.org'
21+
cache: npm
22+
- run: rm -f package-lock.json && npm install
23+
- name: Verify tag matches package.json version
24+
run: |
25+
TAG_VERSION="${GITHUB_REF_NAME#v}"
26+
PKG_VERSION=$(node -p "require('./package.json').version")
27+
if [ "$TAG_VERSION" != "$PKG_VERSION" ]; then
28+
echo "Tag version ($TAG_VERSION) does not match package.json version ($PKG_VERSION)"
29+
exit 1
30+
fi
31+
- run: npm run lint
32+
- run: npm test
33+
- run: npm publish --access public --provenance
34+
env:
35+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)