From 9b77aa4b07456cbc40b40d8cefaa55b6edd5f978 Mon Sep 17 00:00:00 2001 From: GeWuYou <95328647+GeWuYou@users.noreply.github.com> Date: Thu, 29 Jan 2026 12:23:07 +0800 Subject: [PATCH] =?UTF-8?q?fix(workflow):=20=E4=BF=AE=E5=A4=8D=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E6=A0=87=E7=AD=BE=E5=B7=A5=E4=BD=9C=E6=B5=81=E4=B8=AD?= =?UTF-8?q?=E7=9A=84=E9=87=8D=E5=A4=8D=E6=A0=87=E7=AD=BE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加了对现有标签的检查以避免重复创建 - 配置了从正确的提交哈希进行检出 - 在推送标签前验证标签是否已存在 - 添加了标签已存在时的优雅退出机制 - 确保了 Git 配置的一致性设置 --- .github/workflows/auto-tag.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/auto-tag.yml b/.github/workflows/auto-tag.yml index fc62135..fa036b7 100644 --- a/.github/workflows/auto-tag.yml +++ b/.github/workflows/auto-tag.yml @@ -25,8 +25,9 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 + ref: ${{ github.event.workflow_run.head_sha }} persist-credentials: false - + - name: Check for skip keyword id: check_skip run: | @@ -54,7 +55,14 @@ jobs: PAT: ${{ secrets.PAT_TOKEN }} TAG: ${{ steps.version.outputs.new_tag }} run: | + set -e git config user.name "GitHub Action" git config user.email "action@github.com" + + if git show-ref --tags --verify --quiet "refs/tags/$TAG"; then + echo "Tag $TAG already exists, skipping" + exit 0 + fi + git tag -a "$TAG" -m "Auto tag $TAG" - git push "https://x-access-token:${PAT}@github.com/${{ github.repository }}.git" "$TAG" + git push "https://x-access-token:${PAT}@github.com/${{ github.repository }}.git" "$TAG" \ No newline at end of file