From 6ada52b0472010096f783c24d20f020f79b4cadd Mon Sep 17 00:00:00 2001 From: david morales <118213696+davidmoralesz@users.noreply.github.com> Date: Fri, 9 Oct 2026 15:37:45 -0600 Subject: [PATCH] fix(workflows): leave the major tag alone when it already points at the release --- .github/workflows/release.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 93f4b95..0688813 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -74,8 +74,14 @@ jobs: sha="$(git rev-list -n1 "${latest}")" echo "Pointing ${major} at ${latest} (${sha})" - # PATCH fails if the ref does not exist yet, so create it the first time. - if gh api "repos/${GITHUB_REPOSITORY}/git/ref/tags/${major}" >/dev/null 2>&1; then + # PATCH fails if the ref does not exist yet, so create it the first time. A push + # that released nothing leaves the tag where it is: writing the same sha back + # gains nothing, and the API has answered it with a 403. + current="$(gh api "repos/${GITHUB_REPOSITORY}/git/ref/tags/${major}" --jq .object.sha 2>/dev/null || true)" + if [ "${current}" = "${sha}" ]; then + echo "${major} already points at ${sha}" + exit 0 + elif [ -n "${current}" ]; then gh api -X PATCH "repos/${GITHUB_REPOSITORY}/git/refs/tags/${major}" \ -f "sha=${sha}" -F force=true >/dev/null else