fix(release): rewrite with verbose upload diagnostics
dev / Build debug APK (push) Successful in 29s
release / Build & attach release APK (push) Failing after 33s

This commit is contained in:
Incido Developer committed 2026-08-20 13:59:04 +12:00
1 parent a9b90aab9e
commit 57b6cf99d2
1 file changed
+34 -40
+34 -40
View File
@@ -1,6 +1,6 @@
name: release
"on":
on:
push:
tags:
- 'v*.*.*'
@@ -54,10 +54,10 @@ jobs:
echo "PATH=$SDK/cmdline-tools/latest/bin:$SDK/platform-tools:$PATH" >> $GITHUB_ENV
- name: Build debug + release APKs
timeout-minutes: 25
run: |
cd repo
git checkout ${{ github.ref_name }}
mkdir -p keystore
if [ ! -f keystore/release.jks ]; then
keytool -genkey -noprompt -v \
@@ -68,28 +68,20 @@ jobs:
-keypass incido_dev_keystore \
-dname "CN=Incido Dev, OU=Local, O=Incido, L=Local, ST=Local, C=NZ"
fi
export JAVA_HOME=/tmp/gitea-runner-work/jdk
export ANDROID_HOME=/tmp/gitea-runner-work/android-sdk
export PATH=$JAVA_HOME/bin:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools:$PATH
chmod +x ./gradlew
git status
ls -la
ls -la app/build/outputs/apk/release/ 2>/dev/null || echo "No release dir"
ls -la app/build/outputs/apk/debug/ 2>/dev/null || echo "No debug dir"
./gradlew --stop 2>/dev/null || true
./gradlew assembleDebug assembleRelease --no-daemon --stacktrace --rerun-tasks 2>&1 | tee /tmp/build.log
./gradlew assembleDebug assembleRelease --no-daemon --stacktrace 2>&1 | tee /tmp/build.log
BUILD_STATUS=${PIPESTATUS[0]}
echo "Gradle exit status: $BUILD_STATUS"
tail -60 /tmp/build.log
if [ $BUILD_STATUS -ne 0 ]; then
echo "Build failed with exit code $BUILD_STATUS"
echo "Build failed"
tail -100 /tmp/build.log
exit 1
fi
ls -la app/build/outputs/apk/*/release/ 2>/dev/null || true
ls -la app/build/outputs/apk/*/debug/ 2>/dev/null || true
ls -la app/build/outputs/apk/debug/ app/build/outputs/apk/release/
- name: Create release + attach both APKs
env:
@@ -103,26 +95,28 @@ jobs:
APK_DEBUG="Incido-$VERSION-debug.apk"
APK_RELEASE="Incido-$VERSION-release.apk"
echo "Checking for existing release for tag: $TAG"
echo "Tag: $TAG Version: $VERSION"
echo "--- Check for existing release ---"
RELEASE_ID=$(curl -s "$API/releases/tags/$TAG" \
-H "Authorization: token $GH_TOKEN" \
| python3 -c "import sys,json; print(json.load(sys.stdin).get('id','') or '')")
if [ -n "$RELEASE_ID" ]; then
echo "Found existing release ID: $RELEASE_ID (reusing it)"
else
echo "No existing release -- creating one for tag: $TAG"
python3 -c "import sys,json; sys.stdout.write(json.dumps({'tag_name': '$TAG', 'name': '$TAG', 'draft': False, 'prerelease': False}))" \
if [ -z "$RELEASE_ID" ]; then
echo "--- Create release ---"
python3 -c "import sys,json; sys.stdout.write(json.dumps({'tag_name': '$TAG', 'name': '$TAG', 'body': 'Release $TAG', 'draft': False, 'prerelease': False}))" \
> /tmp/release_payload.json
RELEASE_ID=$(curl -s -X POST "$API/releases" \
-H "Authorization: token $GH_TOKEN" \
-H "Content-Type: application/json" \
-d @/tmp/release_payload.json \
| python3 -c "import sys,json; print(json.load(sys.stdin).get('id','') or '')")
else
echo "--- Reusing existing release $RELEASE_ID ---"
fi
echo "Release ID: $RELEASE_ID"
if [ -z "$RELEASE_ID" ]; then echo "ERROR: Failed to get release ID"; exit 1; fi
if [ -z "$RELEASE_ID" ]; then echo "ERROR: no release ID"; exit 1; fi
for APK in "$APK_DEBUG" "$APK_RELEASE"; do
if echo "$APK" | grep -q "debug"; then
@@ -135,28 +129,28 @@ jobs:
exit 1
fi
ASSET_ID=$(python3 - "$API" "$RELEASE_ID" "$APK" "$GH_TOKEN" << 'PYEOF')
echo "--- Deleting stale assets for $APK ---"
python3 - "$API" "$RELEASE_ID" "$APK" "$GH_TOKEN" << "PYEOF"
import sys, json
api, release_id, apk, token = sys.argv[1:]
resp = __import__('urllib.request').urlopen(
__import__('urllib.request').Request(
f"{api}/releases/{release_id}/assets?filename={apk}",
headers={"Authorization": f"token {token}"}))
for a in json.loads(resp.read()).get('assets', []):
if a['name'] == apk:
print(a['id'], flush=True)
break
api, release_id, apk, token = sys.argv[1:5]
from urllib.request import urlopen, Request
resp = urlopen(Request(f"{api}/releases/{release_id}/assets", headers={"Authorization": f"token {token}"}))
for a in json.loads(resp.read()).get("assets", []):
if a["name"] == apk:
d = urlopen(Request(f"{api}/releases/{release_id}/assets/{a["id"]}", method="DELETE", headers={"Authorization": f"token {token}"}))
print(f"Deleted {a["id"]}", flush=True)
PYEOF
if [ -n "$ASSET_ID" ]; then
echo "Deleting stale asset $ASSET_ID ($APK)"
curl -s -X DELETE "$API/releases/$RELEASE_ID/assets/$ASSET_ID" \
-H "Authorization: token $GH_TOKEN" > /dev/null
fi
echo "Attaching $APK to release $RELEASE_ID"
curl -s -X POST "$API/releases/$RELEASE_ID/assets" \
echo "--- Uploading $APK ---"
ls -la "$APK_PATH"
UPLOAD=$(curl -s -X POST "$API/releases/$RELEASE_ID/assets" \
-H "Authorization: token $GH_TOKEN" \
-F "files=@$APK_PATH" \
--max-time 300 --retry 3 --retry-delay 10
--max-time 600 --retry 3 --retry-delay 10)
echo "Upload response: $UPLOAD"
echo "$UPLOAD" | python3 -c "import sys,json; d=json.loads(sys.stdin.read()); print('Asset uploaded:', d.get('name','?'), d.get('id','?'))"
done
echo "--- Final release state ---"
curl -s "$API/releases/$RELEASE_ID" -H "Authorization: token $GH_TOKEN" | python3 -c "import sys,json; d=json.load(sys.stdin); print(f'Release {d["tag_name"]} has {len(d["assets"])} assets')"