From f3d01b5890a5a517f1ee172c5e6d631fe5bf2795 Mon Sep 17 00:00:00 2001 From: funman300 Date: Sat, 16 May 2026 12:20:10 -0700 Subject: [PATCH] fix(ci): delete existing APK assets before upload to avoid duplicates on re-runs Co-Authored-By: Claude Sonnet 4.6 --- .gitea/workflows/android-release.yml | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/android-release.yml b/.gitea/workflows/android-release.yml index b15127c..09072a1 100644 --- a/.gitea/workflows/android-release.yml +++ b/.gitea/workflows/android-release.yml @@ -92,7 +92,22 @@ jobs: - name: Upload APK to release run: | + BASE="${{ env.GITEA_URL }}/api/v1/repos/${{ env.REPO }}" + AUTH="Authorization: token ${{ secrets.CI_TOKEN }}" + RELEASE_ID="${{ steps.release.outputs.id }}" + + # Remove any existing APK assets so re-runs don't accumulate duplicates. + curl -sf -H "$AUTH" "$BASE/releases/$RELEASE_ID/assets" \ + | python3 -c " +import sys, json +for a in json.load(sys.stdin): + if a['name'].endswith('.apk'): + print(a['id']) +" | while read AID; do + curl -sf -X DELETE -H "$AUTH" "$BASE/releases/$RELEASE_ID/assets/$AID" + done + curl -sf -X POST \ - -H "Authorization: token ${{ secrets.CI_TOKEN }}" \ + -H "$AUTH" \ -F "attachment=@${{ env.APK_OUT }};type=application/vnd.android.package-archive" \ - "${{ env.GITEA_URL }}/api/v1/repos/${{ env.REPO }}/releases/${{ steps.release.outputs.id }}/assets" + "$BASE/releases/$RELEASE_ID/assets"