From 93654b4509934272c33de168149746249ada1d0b Mon Sep 17 00:00:00 2001 From: Marc LeBlanc <7050295+marcleblanc2@users.noreply.github.com> Date: Wed, 11 Nov 2026 04:41:16 -0600 Subject: [PATCH] release: Make the tag step safe to retry in both release files Copies the tag step from release.yaml (#1449) to batch-change/release.yaml: keep a tag which already points at the promote commit, and fail if it points anywhere else. Both files now create the release branch with git switch -C, so a retry in a checkout which kept the branch from the first attempt no longer fails. Amp-Thread-ID: https://ampcode.com/threads/T-01a1c7a5-6b65-723b-980c-b85e1e9008b5 Co-authored-by: Amp --- batch-change/release.yaml | 15 ++++++++++++--- release.yaml | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/batch-change/release.yaml b/batch-change/release.yaml index 2534f0a07..22ef5f1ec 100644 --- a/batch-change/release.yaml +++ b/batch-change/release.yaml @@ -136,9 +136,18 @@ promoteToPublic: # Create the final branch holding the tagged commit git checkout "${promote_branch}" - git switch -c "${release_branch}" - - git tag {{version}} + git switch -C "${release_branch}" + + # A retried finalize finds its own tag; only a tag elsewhere is an error + if tagged=$(git rev-parse -q --verify "refs/tags/{{version}}^{commit}"); then + if [ "${tagged}" != "$(git rev-parse HEAD)" ]; then + echo "Tag {{version}} already exists at ${tagged}, not at ${promote_branch} ($(git rev-parse HEAD))" >&2 + exit 1 + fi + echo "Tag {{version}} already points at ${promote_branch}, not recreating it" + else + git tag {{version}} + fi git push origin ${release_branch} --tags # Web URL to the tag diff --git a/release.yaml b/release.yaml index 83206ff7d..6d40af394 100644 --- a/release.yaml +++ b/release.yaml @@ -199,7 +199,7 @@ promoteToPublic: # Create the final branch holding the tagged commit git checkout "${promote_branch}" - git switch -c "${release_branch}" + git switch -C "${release_branch}" # A retried finalize finds its own tag; only a tag elsewhere is an error if tagged=$(git rev-parse -q --verify "refs/tags/{{version}}^{commit}"); then