@@ -32,32 +32,48 @@ jobs:
3232 - name : Get dependencies
3333 run : flutter pub get
3434
35- # Step 6: Build APK
35+ # Step 5: Decode signing secrets for keystore and properties
36+ - name : Decode Signing Secrets
37+ env :
38+ NIGHTLY_KEYSTORE_B64 : ${{ secrets.NIGHTLY_KEYSTORE_B64 }}
39+ NIGHTLY_PROPERTIES_B64 : ${{ secrets.NIGHTLY_PROPERTIES_B64 }}
40+ run : |
41+ echo "$NIGHTLY_KEYSTORE_B64" | base64 --decode > android/nightly.jks
42+ echo "$NIGHTLY_PROPERTIES_B64" | base64 --decode > android/key_nightly.properties
43+
44+ # Step 6: Build the APK with nightly flavor and release mode
3645 - name : Build APK
37- run : flutter build apk --build-number=${{ github.run_number }} --release
38- # No 'mv' command here yet
46+ run : flutter build apk --flavor nightly --build-number=${{ github.run_number }} --release
47+
48+ # Step 7: Verify the APK is signed
49+ - name : Verify sign
50+ run : keytool -printcert -jarfile build/app/outputs/flutter-apk/app-nightly-release.apk
3951
40- # Step 7: Push the APK to the fdroid-repo branch
52+ # Step 8: Configure git and push the APK to fdroid-repo branch
4153 - name : Configure and push to fdroid-repo
4254 run : |
4355 git config --global user.name "github-actions[bot]"
4456 git config --global user.email "github-actions[bot]@users.noreply.github.com"
4557 git fetch origin fdroid-repo:fdroid-repo
4658 git checkout fdroid-repo
47-
48- mkdir -p repo
49- # Don't remove the old APK!
50- # Copy the new APK with a unique name
51- mv build/app/outputs/flutter-apk/app-release.apk repo/com.ccextractor.taskwarriorflutter_${{ github.run_number }}.apk
52-
59+ mv build/app/outputs/flutter-apk/app-nightly-release.apk repo/nightly.${{ github.run_number }}.apk
5360 git add repo/
54- git commit -m "chore: Add new APK from build ${{ github.run_number }}"
55- # You can push here, or wait until after the fdroid update
56- # git push origin fdroid-repo
61+ git commit -m "chore: Add new signed APK from build ${{ github.run_number }}"
5762
58- # Step 8: Setup f-droid and run update
59- - name : Setup F-Droid
60- uses : subosito/flutter-action@v1 # A common action, but you'll need to install fdroidserver
63+ # Step 9: Prune old APKs, keeping only the 5 most recent
64+ - name : Prune Old APKs
65+ run : |
66+ echo "Checking for old APKs to prune..."
67+ if [ $(ls -1 repo/*.apk 2>/dev/null | wc -l) -gt 5 ]; then
68+ echo "More than 5 APKs found. Deleting all but the 5 most recent..."
69+ ls -1 repo/*.apk | sort -V | head -n -5 | xargs rm -f
70+ else
71+ echo "5 or fewer APKs found. No cleanup needed."
72+ fi
73+
74+ # Step 10: Setup F-Droid (install fdroidserver) and update the repo
75+ - name : Fdroid Install
76+ uses : subosito/flutter-action@v1
6177 - name : Run F-Droid Update
6278 env :
6379 FDROID_CONFIG_YML_B64 : ${{ secrets.FDROID_CONFIG_YML }}
7490 # Run the update command, referencing the files
7591 fdroid update -c
7692
77- # Step 9 : Push the updated repo files
93+ # Step 12 : Push the updated repo files with amended commit
7894 - name : Push F-Droid updates
7995 run : |
8096 git add .
81- git commit -m "feat: F-Droid repo update n: ${{ github.run_number }}"
82- git push origin fdroid-repo
97+ git commit --amend - m "chore: Add new signed APK from build ${{ github.run_number }} and update F-Droid metadata "
98+ git push origin fdroid-repo --force
0 commit comments