@@ -2,6 +2,8 @@ import mihon.buildlogic.getBuildTime
2
2
import mihon.buildlogic.getCommitCount
3
3
import mihon.buildlogic.getGitSha
4
4
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
5
+ import java.io.FileInputStream
6
+ import java.util.Properties
5
7
6
8
plugins {
7
9
id(" mihon.android.application" )
@@ -53,6 +55,15 @@ android {
53
55
}
54
56
}
55
57
58
+ signingConfigs {
59
+ create(" preview" ) {
60
+ storeFile = rootProject.file(readPropertyFromLocalProperties(" keystore" ) ? : " keystore.jks" )
61
+ storePassword = readPropertyFromLocalProperties(" storePassword" )
62
+ keyAlias = readPropertyFromLocalProperties(" keyAlias" )
63
+ keyPassword = readPropertyFromLocalProperties(" keyPassword" )
64
+ }
65
+ }
66
+
56
67
buildTypes {
57
68
named(" debug" ) {
58
69
versionNameSuffix = " -${getCommitCount()} "
@@ -78,8 +89,8 @@ android {
78
89
matchingFallbacks.add(" release" )
79
90
versionNameSuffix = " -${getCommitCount()} "
80
91
applicationIdSuffix = " .beta"
81
- signingConfig = signingConfigs.getByName(" debug" )
82
92
}
93
+ // Profilers build, overwrite dev's signing configuration by 'debug' key then re-sign with GitHub's workflow
83
94
create(" benchmark" ) {
84
95
initWith(getByName(" release" ))
85
96
@@ -100,17 +111,21 @@ android {
100
111
flavorDimensions.add(" default" )
101
112
102
113
productFlavors {
114
+ // Include Google service & build unsigned, for GitHub workflow build
103
115
create(" standard" ) {
104
116
buildConfigField(" boolean" , " INCLUDE_UPDATER" , " true" )
105
117
dimension = " default"
106
118
}
107
119
create(" fdroid" ) {
108
120
dimension = " default"
109
121
}
122
+ // Signed, dev build with Android Studio if it's not a debug build
110
123
create(" dev" ) {
111
124
// Include pseudolocales: https://developer.android.com/guide/topics/resources/pseudolocales
112
125
resourceConfigurations.addAll(listOf (" en" , " en_XA" , " ar_XB" , " xxhdpi" ))
113
126
dimension = " default"
127
+ // Default signing for dev flavor, would be overridden by buildTypes config
128
+ signingConfig = signingConfigs.getByName(" preview" )
114
129
}
115
130
}
116
131
@@ -344,3 +359,16 @@ buildscript {
344
359
classpath(kotlinx.gradle)
345
360
}
346
361
}
362
+
363
+ // Config local store's signing key
364
+ fun readPropertyFromLocalProperties (propertyName : String ): String? {
365
+ val localPropertiesFile = rootProject.file(" local.properties" )
366
+ if (localPropertiesFile.exists()) {
367
+ val properties = Properties ()
368
+ FileInputStream (localPropertiesFile).use { inputStream ->
369
+ properties.load(inputStream)
370
+ }
371
+ return properties.getProperty(propertyName)
372
+ }
373
+ return null // Property not found
374
+ }
0 commit comments