ci: fail the Codeberg publish when an upload fails
The asset uploads and the release PATCH only printed their HTTP status, so a failed upload still ended in "Published" and left the release Obtainium follows without its APK or checksum. Each now retries with backoff and fails the job if it never succeeds.
This commit is contained in:
1 parent
67010a632c
commit
6637554c9d
1 file changed
+21
-10
@@ -69,10 +69,12 @@ ID=""
|
||||
for attempt in 1 2 3 4 5 6; do
|
||||
EXIST=$(curl -s -H "Authorization: token $TOKEN" "$API/releases/tags/$TAG" | jq -r '.id // empty' 2>/dev/null || true)
|
||||
if [ -n "$EXIST" ]; then
|
||||
curl -s -o /dev/null -w "release PATCH HTTP %{http_code}\n" -X PATCH \
|
||||
CODE=$(curl -s -o /dev/null -w "%{http_code}" -X PATCH \
|
||||
-H "Authorization: token $TOKEN" -H "Content-Type: application/json" \
|
||||
-d @"$WORK/payload.json" "$API/releases/$EXIST"
|
||||
ID="$EXIST"; break
|
||||
-d @"$WORK/payload.json" "$API/releases/$EXIST")
|
||||
echo "release PATCH attempt $attempt HTTP $CODE"
|
||||
case "$CODE" in 2??) ID="$EXIST"; break ;; esac
|
||||
sleep $((attempt * 10)); continue
|
||||
fi
|
||||
CODE=$(curl -s -o "$WORK/response.json" -w "%{http_code}" -X POST \
|
||||
-H "Authorization: token $TOKEN" -H "Content-Type: application/json" \
|
||||
@@ -84,13 +86,22 @@ for attempt in 1 2 3 4 5 6; do
|
||||
done
|
||||
if [ -z "$ID" ]; then echo "Could not resolve Codeberg release id after retries." >&2; exit 1; fi
|
||||
|
||||
# Attach APK + checksum, replacing any prior asset of the same name.
|
||||
# Attach APK + checksum, replacing any prior asset of the same name. The same
|
||||
# flakiness as above, so each upload retries, and a release left without its
|
||||
# APK or checksum (what Obtainium follows) fails the job rather than passing.
|
||||
for A in "$ASSET_APK" "$ASSET_SUM"; do
|
||||
OLD=$(curl -s -H "Authorization: token $TOKEN" "$API/releases/$ID/assets" \
|
||||
| jq -r --arg n "$A" '.[] | select(.name==$n) | .id')
|
||||
[ -n "$OLD" ] && curl -s -X DELETE -H "Authorization: token $TOKEN" "$API/releases/$ID/assets/$OLD" >/dev/null || true
|
||||
curl -s -X POST -H "Authorization: token $TOKEN" \
|
||||
-F "attachment=@$WORK/$A" \
|
||||
"$API/releases/$ID/assets?name=$A" -o /dev/null -w "asset $A HTTP %{http_code}\n"
|
||||
UPLOADED=""
|
||||
for attempt in 1 2 3 4 5 6; do
|
||||
OLD=$(curl -s -H "Authorization: token $TOKEN" "$API/releases/$ID/assets" \
|
||||
| jq -r --arg n "$A" '.[] | select(.name==$n) | .id' 2>/dev/null || true)
|
||||
[ -n "$OLD" ] && curl -s -X DELETE -H "Authorization: token $TOKEN" "$API/releases/$ID/assets/$OLD" >/dev/null || true
|
||||
CODE=$(curl -s -X POST -H "Authorization: token $TOKEN" \
|
||||
-F "attachment=@$WORK/$A" \
|
||||
"$API/releases/$ID/assets?name=$A" -o /dev/null -w "%{http_code}")
|
||||
echo "asset $A attempt $attempt HTTP $CODE"
|
||||
case "$CODE" in 2??) UPLOADED=1; break ;; esac
|
||||
sleep $((attempt * 10))
|
||||
done
|
||||
if [ -z "$UPLOADED" ]; then echo "Could not upload $A after retries." >&2; exit 1; fi
|
||||
done
|
||||
echo "Published $TAG to Codeberg."
|
||||
Reference in new issue
Block a user