From 43cb716006274783c3a2a817264a6471c1f680b2 Mon Sep 17 00:00:00 2001 From: magdev Date: Sun, 3 May 2026 12:15:07 +0200 Subject: [PATCH] release: delete existing assets before re-upload (don't accumulate dupes) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Each tag rotation re-runs release.yml. The create-release POST returns 4xx for the existing release, the script falls back to GET on the existing one — and then re-POSTs the same asset names to the upload endpoint. Gitea appends each upload as a new asset rather than replacing, so the release page accumulates Todo-x86_64.AppImage once per rotation, same for .zsync / latest.json / SHA256SUMS. Fix: between getting the release id and the upload loop, list all existing assets and DELETE them first. Single rotation = single set of assets, regardless of how many times release.yml has run for this tag. Release body stays as set on first creation (the GET returns the original). If a future rotation needs to refresh the body too, that would be a separate PATCH on the release. Co-Authored-By: Claude Opus 4.7 (1M context) --- .gitea/workflows/release.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 3ac5a57..6f8770f 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -175,6 +175,18 @@ jobs: rid=$(echo "$release_json" | jq -r .id) echo "Release id: $rid" + # Wipe any pre-existing assets so a re-run (e.g. after a tag + # rotation) produces a clean asset list rather than duplicates + # accumulating across runs. + existing=$(curl -fsSL "$api/repos/$REPO/releases/$rid/assets" \ + -H "Authorization: token $GITEA_TOKEN") + for aid in $(echo "$existing" | jq -r '.[].id'); do + echo " deleting old asset $aid" + curl -fsSL -X DELETE \ + "$api/repos/$REPO/releases/$rid/assets/$aid" \ + -H "Authorization: token $GITEA_TOKEN" + done + upload() { local f="$1" echo " uploading $f"