Skip to content

Commit 61c954a

Browse files
committed
【维护】重构版本检查和发布流程
- 移除单独的 check-version-and-push-tag 工作流 - 将版本检查和发布逻辑整合到 release 工作流中 - 更新 release 工作流以支持手动触发和主分支自动发布
1 parent 1cc021a commit 61c954a

2 files changed

Lines changed: 27 additions & 41 deletions

File tree

.github/workflows/check-version-and-push-tag.yml

Lines changed: 0 additions & 38 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
name: release
22

3-
on:
3+
on:
4+
workflow_dispatch:
45
push:
5-
tags:
6-
- "v*"
6+
branches:
7+
- main
78

89
jobs:
910
release:
@@ -14,8 +15,31 @@ jobs:
1415

1516
- name: Checkout
1617
uses: actions/checkout@v4
18+
19+
- name: Check version
20+
id: version-check
21+
run: |
22+
chmod +x ./scripts/is-newer-version.bash
23+
chmod +x ./scripts/get-version.bash
24+
VERSION=$(./scripts/is-newer-version.bash)
25+
echo "version=${VERSION}" >> $GITHUB_OUTPUT
26+
if [ "$VERSION" != "0" ]; then
27+
echo "New version detected: $VERSION"
28+
else
29+
echo "No new version to release"
30+
fi
31+
32+
- name: Push tag
33+
if: steps.version-check.outputs.version != '0'
34+
run: |
35+
tag="v${{ steps.version-check.outputs.version }}"
36+
git config user.name "${GITHUB_ACTOR}"
37+
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
38+
git tag -a "${tag}" -m "Release ${tag}"
39+
git push origin "${tag}"
1740
1841
- name: Create release
42+
if: steps.version-check.outputs.version != '0'
1943
uses: ncipollo/release-action@v1
2044
with:
2145
token: ${{ secrets.TOKEN }}

0 commit comments

Comments
 (0)