Skip to content

Commit 4f38851

Browse files
authoredFeb 2, 2023
fix(CI): fix mobile build artifact with proper signing (immich-app#1504)
1 parent 2c356ec commit 4f38851

File tree

3 files changed

+30
-31
lines changed

3 files changed

+30
-31
lines changed
 

‎.github/workflows/build-mobile.yml

+15-18
Original file line numberDiff line numberDiff line change
@@ -7,50 +7,47 @@ on:
77
push:
88
branches: [main]
99

10-
1110
jobs:
1211
build-sign-android:
1312
name: Build and sign Android
14-
runs-on: ubuntu-latest
15-
13+
runs-on: macos-12
14+
1615
steps:
1716
- uses: actions/checkout@v3
1817

1918
- uses: actions/setup-java@v3
2019
with:
21-
distribution: 'zulu'
20+
distribution: "zulu"
2221
java-version: "12.x"
23-
cache: 'gradle'
22+
cache: "gradle"
2423

2524
- name: Setup Flutter SDK
2625
uses: subosito/flutter-action@v2
2726
with:
28-
channel: 'stable'
29-
flutter-version: '3.3.10'
27+
channel: "stable"
28+
flutter-version: "3.3.10"
3029
cache: true
3130

3231
- name: Create the Keystore
33-
3432
env:
35-
KEYSTORE_BASE64: ${{ secrets.ANDROID_SIGN_KEY_CONTENT }}
36-
run: |
37-
# import keystore from secrets
38-
echo $KEYSTORE_BASE64 | base64 -d > $RUNNER_TEMP/my_production.keystore
33+
KEY_JKS: ${{ secrets.KEY_JKS }}
34+
working-directory: ./mobile
35+
run: echo $KEY_JKS | base64 -d > android/key.jks
3936

40-
- name: Restore packages
37+
- name: Get Packages
4138
working-directory: ./mobile
4239
run: flutter pub get
4340

4441
- name: Build Android App Bundle
4542
working-directory: ./mobile
43+
env:
44+
ALIAS: ${{ secrets.ALIAS }}
45+
ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }}
46+
ANDROID_STORE_PASSWORD: ${{ secrets.ANDROID_STORE_PASSWORD }}
4647
run: flutter build apk --release
4748

48-
- name: Sign Android App Bundle
49-
working-directory: ./mobile
50-
run: jarsigner -keystore $RUNNER_TEMP/my_production.keystore -storepass ${{ secrets.ANDROID_KEY_PASSWORD }} -keypass ${{ secrets.ANDROID_STORE_PASSWORD }} -sigalg SHA256withRSA -digestalg SHA-256 -signedjar build/app/outputs/apk/release/app-release-signed.apk build/app/outputs/apk/release/*.apk ${{ secrets.ALIAS }}
51-
5249
- name: Publish Android Artifact
5350
uses: actions/upload-artifact@v3
5451
with:
5552
name: release-apk-signed
56-
path: mobile/build/app/outputs/apk/release/app-release-signed.apk
53+
path: mobile/build/app/outputs/flutter-apk/app-release.apk

‎.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ uploads
88
coverage
99

1010
mobile/gradle.properties
11-
mobile/openapi/pubspec.lock
11+
mobile/openapi/pubspec.lock
12+
mobile/*.jks

‎mobile/android/app/build.gradle

+13-12
Original file line numberDiff line numberDiff line change
@@ -57,21 +57,22 @@ android {
5757
versionName flutterVersionName
5858
}
5959

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-
// }
60+
signingConfigs {
61+
release {
62+
def keyAliasVal = System.getenv("ALIAS")
63+
def keyPasswordVal = System.getenv("ANDROID_KEY_PASSWORD")
64+
def storePasswordVal = System.getenv("ANDROID_STORE_PASSWORD")
65+
66+
keyAlias keyAliasVal ? keyAliasVal : keystoreProperties['keyAlias']
67+
keyPassword keyPasswordVal ? keyPasswordVal : keystoreProperties['keyPassword']
68+
storeFile file("../key.jks") ? file("../key.jks") : file(keystoreProperties['storeFile'])
69+
storePassword storePasswordVal ? storePasswordVal : keystoreProperties['storePassword']
70+
}
71+
}
6872

6973
buildTypes {
7074
release {
71-
// TODO: Add your own signing config for the release build.
72-
// Signing with the debug keys for now, so `flutter run --release` works.
73-
// signingConfig signingConfigs.release
74-
signingConfig null
75+
signingConfig signingConfigs.release
7576
}
7677
}
7778
}

0 commit comments

Comments
 (0)