diff --git a/.gitea/workflows/build-iso.yaml b/.gitea/workflows/build-iso.yaml index 68fa23d..e9d67a6 100644 --- a/.gitea/workflows/build-iso.yaml +++ b/.gitea/workflows/build-iso.yaml @@ -270,6 +270,9 @@ jobs: uploaded=0 attempt=1 while [ "$attempt" -le "$MAX_ATTEMPTS" ]; do + # Fresh output file each attempt: curl does not truncate -o on + # transport failure, so a stale body must not be misreported. + rm -f "$tmpdir/upload.json" # A previous attempt may have saved the asset but lost the # response; Gitea rejects duplicate names, so only after the # first attempt check for and remove same-name leftovers @@ -292,19 +295,28 @@ jobs: fi fi - if curl -sf -X POST --max-time 600 \ + # Capture HTTP status explicitly: `-f` would swallow the Gitea + # error body (e.g. attachment size-limit messages) and leave the + # failure reason unknown. + if http_code=$(curl -sS -X POST --max-time 600 \ -H "Authorization: token $GITEA_TOKEN" \ -F "attachment=@$iso" \ "$GITEA_API/repos/$REPOSITORY/releases/$RELEASE_ID/assets" \ - -o "$tmpdir/upload.json"; then - if download_url=$(jq -er '.browser_download_url' "$tmpdir/upload.json"); then + -o "$tmpdir/upload.json" -w '%{http_code}'); then + if [ "${http_code:0:1}" = "2" ] \ + && download_url=$(jq -er '.browser_download_url' "$tmpdir/upload.json"); then echo " ✅ Uploaded $fname (attempt $attempt/$MAX_ATTEMPTS): $download_url" uploaded=1 break fi - echo " ⚠️ Upload of $fname returned no download URL (attempt $attempt/$MAX_ATTEMPTS)" >&2 + echo " ⚠️ Upload of $fname: HTTP $http_code (attempt $attempt/$MAX_ATTEMPTS)" >&2 + echo " Response: $(head -c 2000 "$tmpdir/upload.json" 2>/dev/null)" >&2 else - echo " ⚠️ Upload of $fname failed (attempt $attempt/$MAX_ATTEMPTS)" >&2 + rc=$? + echo " ⚠️ Upload of $fname failed (attempt $attempt/$MAX_ATTEMPTS): curl exit $rc, HTTP ${http_code:-000}" >&2 + if [ -s "$tmpdir/upload.json" ]; then + echo " Response: $(head -c 2000 "$tmpdir/upload.json")" >&2 + fi fi if [ "$attempt" -lt "$MAX_ATTEMPTS" ]; then