From 4c7aa7d12281af7cf99a4097c153dd22a8502af8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=B6=E6=9D=96?= Date: Wed, 2 Sep 2026 13:31:00 +0800 Subject: [PATCH] fix(release): preserve annotated tag during checkout --- .github/workflows/release.yml | 5 +++++ script/test_release_scripts.sh | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d4d8acc..c2f416a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -34,6 +34,11 @@ jobs: with: fetch-depth: 0 + - name: Restore annotated release tag + env: + RELEASE_TAG: ${{ github.ref_name }} + run: git fetch --force origin "refs/tags/${RELEASE_TAG}:refs/tags/${RELEASE_TAG}" + - name: Validate release tag id: release_tag env: diff --git a/script/test_release_scripts.sh b/script/test_release_scripts.sh index 5a0ffca..1db990a 100755 --- a/script/test_release_scripts.sh +++ b/script/test_release_scripts.sh @@ -275,6 +275,7 @@ JOB_NAMES=$(awk ' assert_contains "$WORKFLOW" 'group: release-${{ github.repository }}' assert_contains "$WORKFLOW" 'cancel-in-progress: false' assert_not_contains "$WORKFLOW" 'queue:' +assert_contains "$WORKFLOW" 'git fetch --force origin "refs/tags/${RELEASE_TAG}:refs/tags/${RELEASE_TAG}"' assert_contains "$WORKFLOW" "git tag --merged origin/main --list 'v*'" assert_contains "$WORKFLOW" 'ruby script/validate_release_order.rb "$RELEASE_TAG"' assert_contains "$WORKFLOW" 'script/ensure_release_absent.sh "$GITHUB_REPOSITORY" "$RELEASE_TAG"' @@ -294,11 +295,14 @@ assert_not_contains "$WORKFLOW" 'release-notes.html' [[ "$(grep -Fc 'secrets.HOMEBREW_TAP_TOKEN' "$WORKFLOW")" == "1" ]] || fail "Homebrew token must appear only in the tap checkout." [[ ! -e "${ROOT_DIR}/script/validate_release_version.rb" ]] || fail "Obsolete release version helper still exists." +RESTORE_TAG_LINE=$(grep -nF -- 'name: Restore annotated release tag' "$WORKFLOW" | cut -d: -f1) VALIDATE_TAG_LINE=$(grep -nF -- 'name: Validate release tag' "$WORKFLOW" | cut -d: -f1) RELEASE_ABSENT_LINE=$(grep -nF -- 'name: Ensure GitHub Release does not already exist' "$WORKFLOW" | cut -d: -f1) GENERATE_PROJECT_LINE=$(grep -nF -- 'name: Generate Xcode Project' "$WORKFLOW" | cut -d: -f1) -if (( VALIDATE_TAG_LINE >= RELEASE_ABSENT_LINE || RELEASE_ABSENT_LINE >= GENERATE_PROJECT_LINE )); then - fail "GitHub Release absence check must run after tag validation and before project generation." +if (( RESTORE_TAG_LINE >= VALIDATE_TAG_LINE + || VALIDATE_TAG_LINE >= RELEASE_ABSENT_LINE + || RELEASE_ABSENT_LINE >= GENERATE_PROJECT_LINE )); then + fail "Annotated tag restore and release absence checks must run before project generation." fi assert_contains "$PR_WORKFLOW" 'release-scripts:'