fix: remove the moving distribution tag before Forgejo draft promotion
Some checks are pending
CI / vet-build-test (push) Waiting to run

This commit is contained in:
shoemoney 2026-11-27 19:48:52 -06:00
parent ea3bdd4874
commit 72e2a617d4
No known key found for this signature in database
2 changed files with 7 additions and 0 deletions

View file

@ -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"

View file

@ -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):