From e3353f65da9df090100044a84feff60231d8d235 Mon Sep 17 00:00:00 2001 From: Veillax <126523099+Veillax@users.noreply.github.com> Date: Mon, 26 Oct 2026 14:57:03 -0600 Subject: [PATCH] Retry release uploads that hit a proxy timeout, and replace every existing asset on re-run Co-Authored-By: Claude Sonnet 5.5 --- deploy/publish-release.sh | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/deploy/publish-release.sh b/deploy/publish-release.sh index 94b4fa6..d142c49 100644 --- a/deploy/publish-release.sh +++ b/deploy/publish-release.sh @@ -42,19 +42,30 @@ else echo "release $TAG already exists (id $id): replacing its files" fi -existing=$(curl -fsS -H "$AUTH" "$API/releases/$id/assets" | json 'import sys, json +# the ids of the release's assets with a given name (a failed upload can leave a partial one behind) +asset_ids() { + curl -fsS -H "$AUTH" "$API/releases/$id/assets" | "$PY" -c 'import sys, json for a in json.load(sys.stdin): - print(a["id"], a["name"])') + if a["name"] == sys.argv[1]: + print(a["id"])' "$1" +} for f in dist/*.tar.gz dist/*.zip dist/SHA256SUMS; do [ -f "$f" ] || continue name=$(basename "$f") - echo "$existing" | while read -r aid aname; do - if [ "$aname" = "$name" ]; then + n=1 + while :; do + for aid in $(asset_ids "$name"); do curl -fsS -X DELETE -H "$AUTH" "$API/releases/$id/assets/$aid" > /dev/null + done + echo "uploading $name (attempt $n)" + if curl -fsS --max-time 1200 -X POST -H "$AUTH" -F "attachment=@$f" "$API/releases/$id/assets?name=$name" > /dev/null; then + break fi + # large uploads can hit a proxy timeout (HTTP 502); try again + [ "$n" -lt 5 ] || { echo "giving up on $name after $n attempts" >&2; exit 1; } + n=$((n + 1)) + sleep $((n * 10)) done - echo "uploading $name" - curl -fsS -X POST -H "$AUTH" -F "attachment=@$f" "$API/releases/$id/assets?name=$name" > /dev/null done echo "published $SERVER/$REPO/releases/tag/$TAG"