@@ -32,32 +32,48 @@ jobs:
32
32
- name : Get dependencies
33
33
run : flutter pub get
34
34
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
36
45
- 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
39
51
40
- # Step 7: Push the APK to the fdroid-repo branch
52
+ # Step 8: Configure git and push the APK to fdroid-repo branch
41
53
- name : Configure and push to fdroid-repo
42
54
run : |
43
55
git config --global user.name "github-actions[bot]"
44
56
git config --global user.email "github-actions[bot]@users.noreply.github.com"
45
57
git fetch origin fdroid-repo:fdroid-repo
46
58
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
53
60
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 }}"
57
62
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
61
77
- name : Run F-Droid Update
62
78
env :
63
79
FDROID_CONFIG_YML_B64 : ${{ secrets.FDROID_CONFIG_YML }}
74
90
# Run the update command, referencing the files
75
91
fdroid update -c
76
92
77
- # Step 9 : Push the updated repo files
93
+ # Step 12 : Push the updated repo files with amended commit
78
94
- name : Push F-Droid updates
79
95
run : |
80
96
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