Skip to content

Commit 758303e

Browse files
committed
ci(workflow): 重构 release.yml 以支持预发布版本检测和发布
1 parent d87d8bf commit 758303e

1 file changed

Lines changed: 45 additions & 3 deletions

File tree

.github/workflows/release.yml

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,51 @@ on:
77

88
jobs:
99
release:
10-
uses: sxzz/workflows/.github/workflows/release.yml@v1
11-
with:
12-
publish: true
10+
name: Release
11+
runs-on: ubuntu-latest
12+
1313
permissions:
1414
contents: write
1515
id-token: write
16+
17+
steps:
18+
- name: Setup JS
19+
uses: sxzz/workflows/setup-js@v1
20+
with:
21+
fetch-all: true
22+
23+
- name: Generate GitHub Changelog
24+
run: pnpx changelogithub
25+
continue-on-error: true
26+
env:
27+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28+
29+
- name: Detect Version Type
30+
id: detect_version
31+
run: |
32+
VERSION=$(node -p "require('./package.json').version")
33+
if [[ "$VERSION" =~ -[a-zA-Z] ]]; then
34+
echo "is_prerelease=true" >> $GITHUB_OUTPUT
35+
if [[ "$VERSION" =~ -beta ]]; then
36+
echo "tag=beta" >> $GITHUB_OUTPUT
37+
elif [[ "$VERSION" =~ -alpha ]]; then
38+
echo "tag=alpha" >> $GITHUB_OUTPUT
39+
elif [[ "$VERSION" =~ -rc ]]; then
40+
echo "tag=rc" >> $GITHUB_OUTPUT
41+
else
42+
echo "tag=next" >> $GITHUB_OUTPUT
43+
fi
44+
else
45+
echo "is_prerelease=false" >> $GITHUB_OUTPUT
46+
echo "tag=latest" >> $GITHUB_OUTPUT
47+
fi
48+
echo "Version: $VERSION"
49+
50+
- name: Display Version Info
51+
run: |
52+
echo "Version: $(node -p "require('./package.json').version")"
53+
echo "Is Prerelease: ${{ steps.detect_version.outputs.is_prerelease }}"
54+
echo "Tag: ${{ steps.detect_version.outputs.tag }}"
55+
56+
- name: Publish to NPM
57+
run: pnpm publish --access public --no-git-checks --tag ${{ steps.detect_version.outputs.tag }}

0 commit comments

Comments
 (0)