ci: use github.token for package upload (respects permissions:packages:write), fix curl status capture
Some checks failed
Android Build & Publish / android (push) Failing after 1m56s

This commit is contained in:
Giancarmine Salucci
2026-05-24 16:44:15 +02:00
parent e5c85981f8
commit 052728c168

View File

@@ -96,7 +96,7 @@ jobs:
# ── 9. Publish to Gitea generic package registry ─────────────────────────
- name: Publish APKs to Gitea package registry
env:
TOKEN: ${{ secrets.GITEA_TOKEN }}
TOKEN: ${{ github.token }}
run: |
set -euo pipefail
VERSION="${{ github.run_number }}"
@@ -105,13 +105,20 @@ jobs:
upload() {
local src="$1" dst_name="$2"
echo "→ Uploading $dst_name (version $VERSION)…"
HTTP=$(curl --silent --show-error --write-out "%{http_code}" \
# --output /dev/null discards the body; --write-out captures only the 3-digit code
HTTP=$(curl --silent --show-error \
--output /dev/null --write-out "%{http_code}" \
-X PUT \
-H "Authorization: token $TOKEN" \
--upload-file "$src" \
"$BASE/$VERSION/$dst_name")
if [[ "$HTTP" != "20"* ]]; then
echo "✗ Upload failed — HTTP $HTTP"
# Retry once with verbose output for diagnostics
curl -v -X PUT \
-H "Authorization: token $TOKEN" \
--upload-file "$src" \
"$BASE/$VERSION/$dst_name" 2>&1 | tail -30 || true
exit 1
fi
echo "✓ $dst_name → $BASE/$VERSION/$dst_name"