Skip to content

Commit bd7abd6

Browse files
committed
added npm_publish
1 parent c88b574 commit bd7abd6

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

.github/workflows/npm_publish.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: CI
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v3
12+
- uses: actions/setup-node@v3
13+
with:
14+
node-version: '24.x'
15+
registry-url: 'https://registry.npmjs.org'
16+
cache: 'npm'
17+
- name: Check release tag
18+
run: |
19+
VERSION=$(node -p "const ver=require('./package.json').version; ver.startsWith('v') ? ver : 'v' + ver")
20+
TAG=${{ github.ref }}
21+
TAG=${TAG#refs/tags/}
22+
if [ "$VERSION" != "$TAG" ]; then
23+
echo "Error: The release tag ($TAG) does not match the version ($VERSION) in package.json"
24+
exit 1
25+
fi
26+
- run: npm ci
27+
# env:
28+
# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN_READ }}
29+
- run: npm run test
30+
- run: npm run build --if-present
31+
- run: npm publish
32+
env:
33+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN_PUBLISH }}

0 commit comments

Comments
 (0)