Skip to content

Commit 0d2cb50

Browse files
committed
【修复】优化 GitHub Actions 发布流程
- 添加推送标签步骤的输出,以便后续步骤使用 - 修正生成最小化 HTML 文件的命令,使用相对路径 - 更新文件复制步骤,将生成的文件复制到同一目录 - 修改发布 artifacts 的路径,使用相对路径 - 新增删除失败标签的步骤,确保发布失败时清理标签
1 parent c227828 commit 0d2cb50

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

.github/workflows/release.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,14 @@ jobs:
3333
3434
- name: Push tag
3535
if: steps.version-check.outputs.version != '0'
36+
id: push-tag
3637
run: |
3738
tag="v${{ steps.version-check.outputs.version }}"
3839
git config user.name "${GITHUB_ACTOR}"
3940
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
4041
git tag -a "${tag}" -m "Release ${tag}"
4142
git push origin "${tag}"
43+
echo "tag_name=${tag}" >> $GITHUB_OUTPUT
4244
4345
- name: Checkout
4446
if: steps.version-check.outputs.version != '0'
@@ -56,16 +58,16 @@ jobs:
5658

5759
- name: Generate minimized HTML
5860
if: steps.version-check.outputs.version != '0'
59-
run: cargo run --release -- ${{ github.action_path }}/index.html ${{ github.action_path }}/index.min.html
61+
run: cargo run --release -- index.html index.min.html
6062
shell: bash
6163
working-directory: ${{ github.action_path }}
6264

6365
- name: Copy files
6466
if: steps.version-check.outputs.version != '0'
6567
run: |
6668
mkdir -p ../release
67-
cp -v ${{ github.action_path }}/index.html ../release/
68-
cp -v ${{ github.action_path }}/index.min.html ./release/
69+
cp -v index.html ../release/
70+
cp -v index.min.html ../release/
6971
shell: bash
7072
working-directory: ${{ github.action_path }}
7173

@@ -75,4 +77,12 @@ jobs:
7577
with:
7678
generateReleaseNotes: true
7779
tag: "v${{ steps.version-check.outputs.version }}"
78-
artifacts: "${{ github.action_path }}/index.html,${{ github.action_path }}/index.min.html"
80+
artifacts: "../release/index.html,../release/index.min.html"
81+
82+
- name: Delete tag on failure
83+
if: failure() && steps.push-tag.outputs.tag_name != ''
84+
run: |
85+
git config user.name "${GITHUB_ACTOR}"
86+
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
87+
git push --delete origin "${{ steps.push-tag.outputs.tag_name }}"
88+
git tag -d "${{ steps.push-tag.outputs.tag_name }}"

0 commit comments

Comments
 (0)