Skip to content

Commit eb91121

Browse files
committed
fix: update pre/beta release workflow logic
1 parent 1eece41 commit eb91121

1 file changed

Lines changed: 42 additions & 31 deletions

File tree

Lines changed: 42 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,47 @@
11
name: Node.js Package
22

33
on:
4-
release:
5-
types: [created]
4+
release:
5+
types: [created]
66

77
jobs:
8-
build-and-publish:
9-
name: Build and Publish to NPM Registry
10-
11-
runs-on: ubuntu-latest
12-
13-
steps:
14-
- name: Checkout repository
15-
uses: actions/checkout@v4
16-
17-
- name: Use Node.js
18-
uses: actions/setup-node@v4
19-
with:
20-
node-version-file: '.nvmrc'
21-
cache: 'npm'
22-
registry-url: 'https://registry.npmjs.org/'
23-
24-
- name: Install dependencies
25-
run: npm ci
26-
27-
- name: Execute test cases
28-
run: npm test
29-
30-
- name: Build Lib
31-
run: npm run build-lib
32-
33-
- name: Publish to NPM Registry
34-
run: npm publish --access public
35-
env:
36-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
8+
build-and-publish:
9+
name: Build and Publish to NPM Registry
10+
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v4
16+
17+
- name: Use Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version-file: '.nvmrc'
21+
cache: 'npm'
22+
registry-url: 'https://registry.npmjs.org/'
23+
24+
- name: Install dependencies
25+
run: npm ci
26+
27+
- name: Execute test cases
28+
run: npm test
29+
30+
- name: Build Lib
31+
run: npm run build-lib
32+
33+
- name: Publish to NPM Registry
34+
run: |
35+
VERSION=$(node -p "require('./package.json').version")
36+
37+
if [[ $VERSION == *"-beta."* ]]; then
38+
npm publish --access public --tag beta
39+
40+
elif [[ $VERSION == *"-"* ]]; then
41+
npm publish --access public --tag next
42+
43+
else
44+
npm publish --access public
45+
fi
46+
env:
47+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)