release: delete existing assets before re-upload (don't accumulate dupes)
Some checks failed
CI / Quality (push) Successful in 4m6s
Release / Linux AppImage (push) Has been cancelled

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) <noreply@anthropic.com>
This commit is contained in:
2026-05-03 12:15:07 +02:00
parent 5e8db0980e
commit 43cb716006

View File

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