File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Publish to npm
2+
3+ on :
4+ release :
5+ types : [published]
6+ push :
7+ tags :
8+ - ' v*'
9+
10+ permissions :
11+ contents : read
12+
13+ jobs :
14+ publish :
15+ runs-on : ubuntu-latest
16+ steps :
17+ - name : Checkout
18+ uses : actions/checkout@v4
19+
20+ - name : Setup Node.js
21+ uses : actions/setup-node@v4
22+ with :
23+ node-version : ' 20'
24+ registry-url : ' https://registry.npmjs.org'
25+ cache : ' npm'
26+
27+ - name : Verify version matches tag
28+ run : |
29+ TAG_VERSION="${GITHUB_REF#refs/tags/v}"
30+ PKG_VERSION=$(node -p "require('./package.json').version")
31+ if [ "$TAG_VERSION" != "$PKG_VERSION" ]; then
32+ echo "Error: Tag version ($TAG_VERSION) does not match package.json version ($PKG_VERSION)"
33+ exit 1
34+ fi
35+ echo "Version check passed: $PKG_VERSION"
36+
37+ - name : Install dependencies
38+ run : npm ci
39+
40+ - name : Build
41+ run : npm run build
42+
43+ - name : Publish to npm
44+ run : npm publish --access public
45+ env :
46+ NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
You can’t perform that action at this time.
0 commit comments