Skip to content

Commit e24814b

Browse files
committed
【维护】重构 GitHub Actions 工作流
- 移除 check-version-and-push-tag.yml 文件 - 更新 release.yml 文件,增加版本检查和推送标签步骤 - 添加构建项目和生成压缩 HTML 的步骤 - 修复 release job 中的 tag 输入错误
1 parent 1cc021a commit e24814b

2 files changed

Lines changed: 44 additions & 42 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: 44 additions & 4 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,11 +15,50 @@ 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}"
40+
41+
- name: Checkout
42+
uses: actions/checkout@v4
43+
44+
- name: Setup Rust
45+
uses: MatteoH2O1999/setup-rust@v1
46+
47+
- name: Build project
48+
run: cargo build --release
49+
shell: bash
50+
working-directory: ${{ github.action_path }}
51+
52+
- name: Generate minimized HTML
53+
run: cargo run --release -- ${{ github.action_path }}/index.html ${{ github.action_path }}/index.min.html
54+
shell: bash
55+
working-directory: ${{ github.action_path }}
1756

1857
- name: Create release
58+
if: steps.version-check.outputs.version != '0'
1959
uses: ncipollo/release-action@v1
2060
with:
2161
token: ${{ secrets.TOKEN }}
2262
generateReleaseNotes: true
23-
tag: ${{ github.ref_name }}
63+
tag: "v${{ steps.version-check.outputs.version }}"
2464
artifacts: "index.html,index.min.html"

0 commit comments

Comments
 (0)