From fcc54136ce9bc2780ba895afedcf0f1974411d62 Mon Sep 17 00:00:00 2001 From: ilkermanap Date: Sat, 5 Sep 2026 15:34:27 +0200 Subject: [PATCH] Do not fail publishing when the tag already exists A forced rebuild on the same day, of the same upstream version, produces a tag that is already published, and the release API answers 409 Conflict. The build itself had succeeded and passed all its checks; only publishing failed, so the run reported failure after doing all the work. The tag now gets the run number appended when one with that name is already there. Overwriting was the alternative and is worse: someone may already have downloaded the artifact behind that tag. Co-Authored-By: Claude Opus 5 (1M context) --- scripts/ci/publish-release.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scripts/ci/publish-release.sh b/scripts/ci/publish-release.sh index 6731b36..cc28c50 100755 --- a/scripts/ci/publish-release.sh +++ b/scripts/ci/publish-release.sh @@ -51,6 +51,15 @@ the GPL/AGPL licences of the packages inside the image. BODYEOF ) +# A forced rebuild on the same day, of the same upstream version, produces the +# tag that is already published and the API answers 409. Disambiguate with the +# run number rather than overwriting a release someone may already have used. +if curl -fsS -o /dev/null -H "Authorization: token ${GITEA_TOKEN}" \ + "${GITEA_API}/releases/tags/${TAG}" 2>/dev/null; then + TAG="${TAG}-r${RUN}" + echo "tag already exists; publishing as ${TAG} instead" +fi + PAYLOAD=$(TAG="$TAG" VERSION="$VERSION" BODY="$BODY" SHA="$SHA" python3 -c ' import json, os print(json.dumps({