Skip to content

Commit 4303966

Browse files
Adding release signing for code magic
1 parent 8a7e62a commit 4303966

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

android/app/build.gradle

+25-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ if (flutterRoot == null) {
1414
apply plugin: 'com.android.application'
1515
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
1616

17+
def keystoreProperties = new Properties()
18+
def keystorePropertiesFile = rootProject.file('key.properties')
19+
if (keystorePropertiesFile.exists()) {
20+
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
21+
}
22+
1723
android {
1824
compileSdkVersion 29
1925

@@ -30,10 +36,27 @@ android {
3036
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
3137
}
3238

39+
signingConfigs {
40+
release {
41+
if (System.getenv()["CI"]) { // CI=true is exported by Codemagic
42+
storeFile file(System.getenv()["FCI_KEYSTORE_PATH"])
43+
storePassword System.getenv()["FCI_KEYSTORE_PASSWORD"]
44+
keyAlias System.getenv()["FCI_KEY_ALIAS"]
45+
keyPassword System.getenv()["FCI_KEY_PASSWORD"]
46+
} else {
47+
keyAlias keystoreProperties['keyAlias']
48+
keyPassword keystoreProperties['keyPassword']
49+
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
50+
storePassword keystoreProperties['storePassword']
51+
}
52+
}
53+
}
54+
3355
buildTypes {
3456
release {
35-
// TODO: Add your own signing config for the release build.
36-
// Signing with the debug keys for now, so `flutter run --release` works.
57+
signingConfig signingConfigs.release
58+
}
59+
debug {
3760
signingConfig signingConfigs.debug
3861
}
3962
}

0 commit comments

Comments
 (0)