fix: improve upload error handling and include file size in upload logs
All checks were successful
Release Electron App / release-desktop (push) Successful in 10m53s

This commit is contained in:
2026-03-03 21:46:09 +01:00
parent f028270e63
commit 7ed7cd70bc

View File

@@ -85,20 +85,26 @@ jobs:
local attempt=1
while [ $attempt -le $MAX_RETRIES ]; do
echo "Uploading ${name} (attempt ${attempt}/${MAX_RETRIES})..."
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" \
local filesize
filesize=$(stat -c%s "$file" 2>/dev/null || stat -f%z "$file" 2>/dev/null || echo "unknown")
echo "Uploading ${name} (${filesize} bytes, attempt ${attempt}/${MAX_RETRIES})..."
RESPONSE=$(curl -s -w "\n%{http_code}" \
--max-time 300 \
-X POST \
-H "Authorization: token ${TOKEN}" \
-H "Expect:" \
-F "attachment=@${file}" \
"${GITEA_URL}/api/v1/repos/${REPO}/releases/${RELEASE_ID}/assets?name=${encoded_name}")
HTTP_CODE=$(echo "$RESPONSE" | tail -1)
BODY=$(echo "$RESPONSE" | head -n -1)
if [ "$HTTP_CODE" -ge 200 ] && [ "$HTTP_CODE" -lt 300 ]; then
if [ "$HTTP_CODE" -ge 200 ] 2>/dev/null && [ "$HTTP_CODE" -lt 300 ] 2>/dev/null; then
echo "✅ Uploaded ${name}"
return 0
fi
echo "⚠️ Upload failed (HTTP ${HTTP_CODE}), retrying in 5s..."
echo "⚠️ Upload failed (HTTP ${HTTP_CODE}), body: ${BODY}"
echo "Retrying in 5s..."
sleep 5
attempt=$((attempt + 1))
done