Skip to content

Commit 4166736

Browse files
committed
added publish script
1 parent e6d37d2 commit 4166736

1 file changed

Lines changed: 46 additions & 0 deletions

File tree

.github/workflows/npm.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Publish to npm
2+
3+
on:
4+
push:
5+
tags:
6+
- "v[0-9]+.[0-9]+.[0-9]+"
7+
- "v[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+"
8+
9+
jobs:
10+
publish:
11+
runs-on: ubuntu-latest
12+
timeout-minutes: 10
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: 24
21+
cache: npm
22+
registry-url: "https://registry.npmjs.org/"
23+
24+
- name: Determine pre-release tag
25+
run: |
26+
TAG_NAME=${GITHUB_REF#refs/tags/}
27+
echo "Detected tag: $TAG_NAME"
28+
if [[ "$TAG_NAME" == *-alpha.* ]]; then
29+
echo "tag=alpha" >> $GITHUB_ENV
30+
else
31+
echo "tag=latest" >> $GITHUB_ENV
32+
fi
33+
34+
- name: Install dependencies
35+
run: npm ci
36+
37+
- name: Run tests
38+
run: npm test
39+
40+
- name: Build
41+
run: npm run build
42+
43+
- name: Publish
44+
run: npm publish --access public --tag ${{ env.tag }}
45+
env:
46+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)