From 7ffae1e8697b8eb47f70f6eee9bb5f65efbd2022 Mon Sep 17 00:00:00 2001 From: Craig Martin Date: Fri, 4 Dec 2026 13:32:15 -0500 Subject: [PATCH] Read exact refs in the release workflow's branch and tag checks git ls-remote also lists refs whose names end in the requested one. The Version Packages job's check that its push is the line's head, and the publish job's check for an existing tag, now keep only the exact ref from its output. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/release.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 032bac1eddf..1b9c5efba27 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -59,7 +59,8 @@ jobs: id: line-head run: | set -euo pipefail - HEAD_SHA=$(git ls-remote "https://github.com/$GITHUB_REPOSITORY" "refs/heads/$GITHUB_REF_NAME" | cut -f 1) + # ls-remote also lists refs whose names end in this one, so keep only the exact ref. + HEAD_SHA=$(git ls-remote "https://github.com/$GITHUB_REPOSITORY" "refs/heads/$GITHUB_REF_NAME" | awk -v ref="refs/heads/$GITHUB_REF_NAME" '$2 == ref {print $1}') if [ "$HEAD_SHA" = "$GITHUB_SHA" ]; then echo "current=true" >> "$GITHUB_OUTPUT" else @@ -332,7 +333,8 @@ jobs: TAG: ${{ needs.check.outputs.version }} run: | set -euo pipefail - if git ls-remote --exit-code --tags origin "$TAG" >/dev/null 2>&1; then + # ls-remote also lists refs whose names end in the tag's, so look for the exact ref. + if git ls-remote origin "refs/tags/$TAG" | awk -v ref="refs/tags/$TAG" '$2 == ref {found = 1} END {exit !found}'; then echo "Tag $TAG already exists, skipping" exit 0 fi