Skip to content

Commit 4a855fe

Browse files
authored
signed apks and optimize repo size at fdroid-repo (#503)
1. This will modify build.gradle to sign nightly builds as well 2. This will use updated workflow to optimize repo size by skipping git commits 3. also will delete apks older than 5 commits(of main) in /repo(in fdroid-repo)
1 parent 0156e16 commit 4a855fe

File tree

4 files changed

+84
-43
lines changed

4 files changed

+84
-43
lines changed

.github/workflows/flutterci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ jobs:
3737
# - run: flutter test
3838

3939
# Step 8: Build APK using flutter build apk
40-
- run: flutter build apk
40+
- run: flutter build apk --release --flavor production
4141

4242
# Step 9: Upload the built APK as an artifact
4343
- uses: actions/upload-artifact@v4
4444
with:
4545
name: release-apk
46-
path: build/app/outputs/apk/release/app-release.apk
46+
path: build/app/outputs/flutter-apk/app-production-release.apk

.github/workflows/nightlydepolyci.yml

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -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 }}
@@ -74,9 +90,9 @@ jobs:
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

android/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ GeneratedPluginRegistrant.java
1111
key.properties
1212
**/*.keystore
1313
**/*.jks
14+
key_nightly.properties

android/app/build.gradle

Lines changed: 46 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,18 @@ def keystoreProperties = new Properties()
2626
def keystorePropertiesFile = rootProject.file('key.properties')
2727
if (keystorePropertiesFile.exists()) {
2828
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
29-
}
29+
}
30+
31+
def nightlyKeystoreProperties = new Properties()
32+
def nightlyKeystorePropertiesFile = rootProject.file('key_nightly.properties')
33+
if (nightlyKeystorePropertiesFile.exists()) {
34+
nightlyKeystoreProperties.load(new FileInputStream(nightlyKeystorePropertiesFile))
35+
}
36+
3037
android {
3138
namespace "com.ccextractor.taskwarriorflutter"
3239
compileSdkVersion 35
3340

34-
// compileSdkVersion flutter.compileSdkVersion
35-
36-
3741
compileOptions {
3842
sourceCompatibility JavaVersion.VERSION_1_8
3943
targetCompatibility JavaVersion.VERSION_1_8
@@ -47,35 +51,55 @@ android {
4751
main.java.srcDirs += 'src/main/kotlin'
4852
}
4953

54+
signingConfigs {
55+
production {
56+
keyAlias keystoreProperties['keyAlias']
57+
keyPassword keystoreProperties['keyPassword']
58+
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
59+
storePassword keystoreProperties['storePassword']
60+
}
61+
nightly {
62+
keyAlias nightlyKeystoreProperties['keyAlias']
63+
keyPassword nightlyKeystoreProperties['keyPassword']
64+
storeFile nightlyKeystoreProperties['storeFile'] ? file(nightlyKeystoreProperties['storeFile']) : null
65+
storePassword nightlyKeystoreProperties['storePassword']
66+
}
67+
}
68+
5069
defaultConfig {
51-
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
52-
applicationId "com.ccextractor.taskwarriorflutter"
53-
//minSdkVersion flutter.minSdkVersion
54-
minSdkVersion flutter.minSdkVersion
70+
minSdkVersion flutter.minSdkVersion
5571
targetSdkVersion 33
5672
versionCode flutterVersionCode.toInteger()
5773
versionName flutterVersionName
5874
}
5975

60-
signingConfigs {
61-
release {
62-
keyAlias keystoreProperties['keyAlias']
63-
keyPassword keystoreProperties['keyPassword']
64-
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
65-
storePassword keystoreProperties['storePassword']
66-
}
67-
}
68-
buildTypes {
69-
release {
70-
signingConfig signingConfigs.debug
71-
}
72-
}
76+
flavorDimensions "default"
77+
productFlavors {
78+
production {
79+
dimension "default"
80+
applicationId "com.ccextractor.taskwarrior"
81+
signingConfig keystoreProperties.isEmpty() ? signingConfigs.debug : signingConfigs.production
82+
}
83+
nightly {
84+
dimension "default"
85+
applicationId "com.ccextractor.taskwarrior.nightly"
86+
versionNameSuffix "-nightly"
87+
signingConfig nightlyKeystoreProperties.isEmpty() ? signingConfigs.debug : signingConfigs.nightly
88+
}
89+
}
90+
91+
buildTypes {
92+
release {
93+
minifyEnabled false
94+
shrinkResources false
95+
}
96+
}
7397
}
7498

7599
flutter {
76100
source '../..'
77101
}
78102

79103
dependencies {
80-
81104
}
105+

0 commit comments

Comments
 (0)