From a447adced45259ce32fb0963c508438601bc0d37 Mon Sep 17 00:00:00 2001 From: LeonMMcoset <152147508+Leonmmcoset@users.noreply.github.com> Date: Sat, 6 Sep 2025 18:09:33 +0800 Subject: [PATCH] Update release-auto-commit.yml --- .github/workflows/release-auto-commit.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-auto-commit.yml b/.github/workflows/release-auto-commit.yml index 17c1bc1..8985fa0 100644 --- a/.github/workflows/release-auto-commit.yml +++ b/.github/workflows/release-auto-commit.yml @@ -16,11 +16,21 @@ jobs: - name: Get previous release tag id: prev_tag run: | + # 强制获取所有标签(防止标签未被拉取) + git fetch --tags + + # 尝试获取上一个标签 PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null) - if [ -z "$PREV_TAG" ]; then + + # 严格验证是否为有效标签(非空且存在于标签列表中) + if [ -n "$PREV_TAG" ] && git tag --list | grep -q "^$PREV_TAG$"; then + : # 有效标签,不做处理 + else PREV_TAG="initial-commit" fi - echo "prev_tag=${PREV_TAG//$'\n'/}" >> "$GITHUB_OUTPUT" + + # 彻底清理输出值(移除所有特殊字符) + echo "prev_tag=$(echo "$PREV_TAG" | tr -d '\n')" >> "$GITHUB_OUTPUT" - name: Generate commit log id: commit_log