From 85c47eddf8d437d1e5405bdb1b2b61077095140d Mon Sep 17 00:00:00 2001 From: ilkermanap Date: Sat, 5 Sep 2026 15:34:30 +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 f5091f1..e3f0749 100755 --- a/scripts/ci/publish-release.sh +++ b/scripts/ci/publish-release.sh @@ -53,6 +53,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({