Skip to content

Commit cc264d0

Browse files
johnscaclaude
andcommitted
also require the tag to be unmoved before cleanup deletes it
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent 631e97b commit cc264d0

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

‎.github/workflows/cut-release.yml‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,17 @@ jobs:
200200
claimed=0
201201
cleanup() {
202202
[ "${claimed}" = 1 ] || return 0
203-
local releases
203+
local ref_sha releases
204+
# Both conditions are load-bearing and neither replaces the other.
205+
# `claimed` answers whether this run created the tag, which the
206+
# commit cannot: a tag that beat us to the name is almost always
207+
# at this same commit. The commit answers whether anyone has moved
208+
# the tag since, which `claimed` cannot. Dropping either one makes
209+
# this destroy a tag it does not own.
210+
ref_sha=$(gh api "repos/${GITHUB_REPOSITORY}/git/ref/tags/${TAG}" --jq .object.sha 2>/dev/null) || return 0
211+
if [ "${ref_sha}" != "${COMMIT}" ]; then
212+
return 0
213+
fi
204214
# The release call can land while this run dies before clearing
205215
# the trap, so a tag of ours can already be locked. Listing
206216
# answers "no release" with an empty result and a success, which

0 commit comments

Comments
 (0)