Skip to content

Commit 017ce7b

Browse files
committed
feat: add Codemagic configuration for automated Android builds and signing
1 parent 7232920 commit 017ce7b

2 files changed

Lines changed: 60 additions & 5 deletions

File tree

android/app/build.gradle

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,17 @@ android {
5656

5757
signingConfigs {
5858
release {
59-
keyAlias keystoreProperties['keyAlias']
60-
keyPassword keystoreProperties['keyPassword']
61-
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
62-
storePassword keystoreProperties['storePassword']
59+
if (System.getenv()["CI"]) { // CI=true is exported by Codemagic
60+
storeFile file(System.getenv()["CM_KEYSTORE_PATH"])
61+
storePassword System.getenv()["CM_KEYSTORE_PASSWORD"]
62+
keyAlias System.getenv()["CM_KEY_ALIAS"]
63+
keyPassword System.getenv()["CM_KEY_PASSWORD"]
64+
} else {
65+
keyAlias keystoreProperties['keyAlias']
66+
keyPassword keystoreProperties['keyPassword']
67+
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
68+
storePassword keystoreProperties['storePassword']
69+
}
6370
}
6471
}
6572

@@ -68,7 +75,7 @@ android {
6875
minifyEnabled true
6976
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
7077
shrinkResources true
71-
if (keystoreProperties['storeFile'] != null) {
78+
if (keystoreProperties['storeFile'] != null || System.getenv()["CI"]) {
7279
signingConfig signingConfigs.release
7380
} else {
7481
signingConfig signingConfigs.debug

codemagic.yaml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
workflows:
2+
flutter-android:
3+
name: Flutter Android
4+
instance_type: mac_mini_m2
5+
max_build_duration: 120
6+
environment:
7+
android_signing:
8+
- codemagic_keystore
9+
groups:
10+
- google_play
11+
- sentry
12+
vars:
13+
PACKAGE_NAME: "com.darshan.heartry"
14+
GOOGLE_PLAY_TRACK: "beta"
15+
flutter: stable
16+
scripts:
17+
- name: Set up local.properties
18+
script: |
19+
echo "flutter.sdk=$HOME/programs/flutter" > "$CM_BUILD_DIR/android/local.properties"
20+
- name: Get Flutter packages
21+
script: |
22+
flutter packages pub get
23+
- name: Run Flutter tests
24+
script: |
25+
flutter test
26+
- name: Setup sentry.properties
27+
script: |
28+
echo "$SENTRY_PROPERTIES" | base64 --decode > sentry.properties
29+
- name: Build AAB with Flutter
30+
script: |
31+
LATEST_BUILD_NUMBER=$(($(google-play get-latest-build-number --package-name "$PACKAGE_NAME" --tracks="$GOOGLE_PLAY_TRACK")))
32+
flutter build appbundle --release \
33+
--dart-define="GOOGLE_CLIENT_ID=$GOOGLE_CLIENT_ID" \
34+
--dart-define="SENTRY_DSN=$SENTRY_DSN"
35+
artifacts:
36+
- build/**/outputs/**/*.aab
37+
- build/**/outputs/**/mapping.txt
38+
- flutter_drive.log
39+
publishing:
40+
email:
41+
recipients:
42+
- darshandrander@outlook.com
43+
notify:
44+
success: true
45+
failure: true
46+
google_play:
47+
credentials: $GOOGLE_PLAY_SERVICE_ACCOUNT_CREDENTIALS
48+
track: $GOOGLE_PLAY_TRACK

0 commit comments

Comments
 (0)