Skip to content

Commit 32e2ca3

Browse files
committed
ci: update npm tag
1 parent aa3eebb commit 32e2ca3

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

.github/workflows/relese.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ name: Release
44
on:
55
push:
66
tags:
7-
- 'v*'
7+
- "v*"
88
# 任务,定义个changelog 的任务
99
jobs:
1010
changelog:
@@ -27,13 +27,25 @@ jobs:
2727
# 安装依赖
2828
- name: Install dependencies
2929
run: npm install
30+
31+
# 获取 tag 的版本类型(alpha 或 beta)
32+
- name: Determine release tag
33+
id: determine_tag
34+
run: |
35+
TAG=$(echo "${GITHUB_REF}" | sed 's/refs\/tags\/\(.*\)/\1/')
36+
PRERELEASE=$(echo $TAG | sed -n 's/.*-\(alpha\|beta\|rc\).*/\1/p')
37+
if [ -n "$PRERELEASE" ]; then
38+
echo "::set-output name=tag::$PRERELEASE"
39+
else
40+
echo "::set-output name=tag::latest"
41+
fi
3042
# # 打包
3143
# - name: Build Packages
3244
# run: pnpm run build
3345
# 发布npm 发布前执行了prepublishOnly
3446
- name: Publish npm
35-
run: npm publish
47+
run: npm publish --tag ${{ steps.determine_tag.outputs.tag }}
3648
env:
3749
# 这里需要几个 Token 变量
3850
# NPM_TOKEN 需要在 npm 网站生成
39-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
51+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)