Skip to content

Commit f5564b3

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

2 files changed

Lines changed: 46 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: 46 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,52 @@ jobs:
1415

1516
- name: Checkout
1617
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Check version
22+
id: version-check
23+
run: |
24+
chmod +x ./scripts/is-newer-version.bash
25+
chmod +x ./scripts/get-version.bash
26+
VERSION=$(./scripts/is-newer-version.bash)
27+
echo "version=${VERSION}" >> $GITHUB_OUTPUT
28+
if [ "$VERSION" != "0" ]; then
29+
echo "New version detected: $VERSION"
30+
else
31+
echo "No new version to release"
32+
fi
33+
34+
- name: Push tag
35+
if: steps.version-check.outputs.version != '0'
36+
run: |
37+
tag="v${{ steps.version-check.outputs.version }}"
38+
git config user.name "${GITHUB_ACTOR}"
39+
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
40+
git tag -a "${tag}" -m "Release ${tag}"
41+
git push origin "${tag}"
42+
43+
- name: Checkout
44+
uses: actions/checkout@v4
45+
46+
- name: Setup Rust
47+
uses: MatteoH2O1999/setup-rust@v1
48+
49+
- name: Build project
50+
run: cargo build --release
51+
shell: bash
52+
working-directory: ${{ github.action_path }}
53+
54+
- name: Generate minimized HTML
55+
run: cargo run --release -- ${{ github.action_path }}/index.html ${{ github.action_path }}/index.min.html
56+
shell: bash
57+
working-directory: ${{ github.action_path }}
1758

1859
- name: Create release
60+
if: steps.version-check.outputs.version != '0'
1961
uses: ncipollo/release-action@v1
2062
with:
2163
token: ${{ secrets.TOKEN }}
2264
generateReleaseNotes: true
23-
tag: ${{ github.ref_name }}
65+
tag: "v${{ steps.version-check.outputs.version }}"
2466
artifacts: "index.html,index.min.html"

0 commit comments

Comments
 (0)