Forráskód Böngészése

【修复】优化 GitHub Actions 发布流程

- 添加推送标签步骤的输出,以便后续步骤使用
- 修正生成最小化 HTML 文件的命令,使用相对路径
- 更新文件复制步骤,将生成的文件复制到同一目录
- 修改发布 artifacts 的路径,使用相对路径
- 新增删除失败标签的步骤,确保发布失败时清理标签
PJ568 1 éve
szülő
commit
cbc697f53b
1 módosított fájl, 14 hozzáadás és 4 törlés
  1. 14 4
      .github/workflows/release.yml

+ 14 - 4
.github/workflows/release.yml

@@ -33,12 +33,14 @@ jobs:
 
     - name: Push tag
       if: steps.version-check.outputs.version != '0'
+      id: push-tag
       run: |
         tag="v${{ steps.version-check.outputs.version }}"
         git config user.name "${GITHUB_ACTOR}"
         git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
         git tag -a "${tag}" -m "Release ${tag}"
         git push origin "${tag}"
+        echo "tag_name=${tag}" >> $GITHUB_OUTPUT
 
     - name: Checkout
       if: steps.version-check.outputs.version != '0'
@@ -56,7 +58,7 @@ jobs:
 
     - name: Generate minimized HTML
       if: steps.version-check.outputs.version != '0'
-      run: cargo run --release -- ${{ github.action_path }}/index.html ${{ github.action_path }}/index.min.html
+      run: cargo run --release -- index.html index.min.html
       shell: bash
       working-directory: ${{ github.action_path }}
 
@@ -64,8 +66,8 @@ jobs:
       if: steps.version-check.outputs.version != '0'
       run: |
         mkdir -p ../release
-        cp -v ${{ github.action_path }}/index.html ../release/
-        cp -v ${{ github.action_path }}/index.min.html ./release/
+        cp -v index.html ../release/
+        cp -v index.min.html ../release/
       shell: bash
       working-directory: ${{ github.action_path }}
 
@@ -75,4 +77,12 @@ jobs:
       with:
         generateReleaseNotes: true
         tag: "v${{ steps.version-check.outputs.version }}"
-        artifacts: "${{ github.action_path }}/index.html,${{ github.action_path }}/index.min.html"
+        artifacts: "../release/index.html,../release/index.min.html"
+
+    - name: Delete tag on failure
+      if: failure() && steps.push-tag.outputs.tag_name != ''
+      run: |
+        git config user.name "${GITHUB_ACTOR}"
+        git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
+        git push --delete origin "${{ steps.push-tag.outputs.tag_name }}"
+        git tag -d "${{ steps.push-tag.outputs.tag_name }}"