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