Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading