Skip to content

Commit 6c3eb95

Browse files
committed
【维护】重构 GitHub Actions 工作流
- 移除 check-version-and-push-tag.yml 文件 - 更新 release.yml 文件,增加版本检查和推送标签的步骤 - 添加构建项目和生成压缩 HTML 的步骤 - 修改发布 release 的步骤,使用检查到的版本号
1 parent 1cc021a commit 6c3eb95

2 files changed

Lines changed: 50 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: 50 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,56 @@ 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+
if: steps.version-check.outputs.version != '0'
45+
uses: actions/checkout@v4
46+
47+
- name: Setup Rust
48+
if: steps.version-check.outputs.version != '0'
49+
uses: MatteoH2O1999/setup-rust@v1
50+
51+
- name: Build project
52+
if: steps.version-check.outputs.version != '0'
53+
run: cargo build --release
54+
shell: bash
55+
working-directory: ${{ github.action_path }}
56+
57+
- name: Generate minimized HTML
58+
if: steps.version-check.outputs.version != '0'
59+
run: cargo run --release -- ${{ github.action_path }}/index.html ${{ github.action_path }}/index.min.html
60+
shell: bash
61+
working-directory: ${{ github.action_path }}
1762

1863
- name: Create release
64+
if: steps.version-check.outputs.version != '0'
1965
uses: ncipollo/release-action@v1
2066
with:
2167
token: ${{ secrets.TOKEN }}
2268
generateReleaseNotes: true
23-
tag: ${{ github.ref_name }}
69+
tag: "v${{ steps.version-check.outputs.version }}"
2470
artifacts: "index.html,index.min.html"

0 commit comments

Comments
 (0)