File tree Expand file tree Collapse file tree 2 files changed +50
-0
lines changed
Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Publish to npm
2+
3+ on :
4+ push :
5+ tags :
6+ - ' v*'
7+
8+ jobs :
9+ publish :
10+ runs-on : ubuntu-latest
11+
12+ steps :
13+ - name : Checkout repository
14+ uses : actions/checkout@v4
15+
16+ - name : Setup Node.js
17+ uses : actions/setup-node@v4
18+ with :
19+ node-version : 20
20+ registry-url : ' https://registry.npmjs.org/'
21+
22+ - name : Install dependencies
23+ run : npm ci
24+
25+ - name : Build
26+ run : npm run build
27+
28+ - name : Determine npm tag
29+ id : tag
30+ run : |
31+ # Extract tag name without "refs/tags/"
32+ TAG_REF=${GITHUB_REF#refs/tags/}
33+ echo "Detected Git tag: $TAG_REF"
34+
35+ # Determine npm tag
36+ if [[ "$TAG_REF" == *-* ]]; then
37+ # prerelease (contains a hyphen)
38+ NPM_TAG=$(echo "$TAG_REF" | sed -E 's/^v[0-9]+\.[0-9]+\.[0-9]+-([a-zA-Z0-9]+).*/\1/')
39+ else
40+ NPM_TAG="latest"
41+ fi
42+ echo "npm publish will use tag: $NPM_TAG"
43+ echo "tag=$NPM_TAG" >> $GITHUB_OUTPUT
44+
45+ - name : Publish to npm
46+ env :
47+ NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
48+ run : npm publish --tag ${{ steps.tag.outputs.tag }}
Original file line number Diff line number Diff line change 11. *
2+
3+ ! /.github
24! /.gitignore
35node_modules
You can’t perform that action at this time.
0 commit comments