From 72e2a617d4d31194a3f4c50d7c193edd47073e4e Mon Sep 17 00:00:00 2001 From: shoemoney Date: Fri, 27 Nov 2026 19:48:52 -0600 Subject: [PATCH] fix: remove the moving distribution tag before Forgejo draft promotion --- scripts/release.sh | 6 ++++++ scripts/test-release.py | 1 + 2 files changed, 7 insertions(+) diff --git a/scripts/release.sh b/scripts/release.sh index 0450bad..0db94e5 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -72,6 +72,12 @@ count=$(api "$API/repos/$REPO/releases/$rel_id" | python3 -c 'import json,sys;pr [ "$count" = 15 ] || { echo "Expected 15 assets, got $count; leaving draft unpublished" >&2; exit 1; } # Keep the existing moving release until the replacement is fully uploaded. if [ -n "$old_id" ]; then api -X DELETE "$API/repos/$REPO/releases/$old_id" >/dev/null; fi +# Forgejo cannot publish a renamed draft onto an existing tag (it returns 500). +# Remove only the moving distribution tag after uploads; version tags stay fixed. +if [ "$TAG" = latest ]; then + code=$(curl -sSL "${auth[@]}" -X DELETE -o "$old_json" -w '%{http_code}' "$API/repos/$REPO/tags/latest") + case "$code" in 200|204|404) ;; *) echo "Moving tag removal failed: HTTP $code" >&2; exit 1;; esac +fi api -X PATCH "$API/repos/$REPO/releases/$rel_id" -H 'Content-Type: application/json' \ -d "$(python3 -c 'import json,sys;print(json.dumps(dict(tag_name=sys.argv[1],draft=False)))' "$TAG")" >/dev/null echo "https://git.shoemoney.ai/$REPO/releases/tag/$TAG" diff --git a/scripts/test-release.py b/scripts/test-release.py index e41bb58..7fdef44 100644 --- a/scripts/test-release.py +++ b/scripts/test-release.py @@ -105,6 +105,7 @@ class ReleaseTest(unittest.TestCase): methods = [method for method, _, _ in self.calls] delete_index = methods.index('DELETE') self.assertGreater(delete_index, max(i for i, (_, path, _) in enumerate(self.calls) if '/assets?' in path)) + self.assertTrue(any(method == 'DELETE' and path.endswith('/tags/latest') for method, path, _ in self.calls)) self.assertEqual(json.loads(self.calls[-1][2])['tag_name'], 'latest') def test_upload_failure_keeps_existing_latest(self):