Skip to content

Commit a2ba4f6

Browse files
A Refactor of signing config to simplify keystore handling
The `app/build.gradle.kts` file has been updated to simplify the release signing configuration. The previous implementation included logic to decode a base64 encoded keystore from an environment variable (`KEY_STORE_FILE`) and write it to a temporary file. This logic, along with the associated `Base64` import, has been removed. The new configuration now directly references the `mLauncher.jks` file within the `app/` directory and retrieves the keystore password, key alias, and key password from their respective environment variables. This change assumes the keystore file is present at build time, streamlining the signing process within the Gradle script.
1 parent f33da3a commit a2ba4f6

File tree

1 file changed

+9
-36
lines changed

1 file changed

+9
-36
lines changed

app/build.gradle.kts

Lines changed: 9 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import java.util.Base64
2-
31
plugins {
42
alias(libs.plugins.android.application)
53
alias(libs.plugins.kotlin.android)
@@ -72,43 +70,18 @@ android {
7270
}
7371

7472
signingConfigs {
75-
val keystoreB64: String =
76-
System.getenv("KEY_STORE_FILE") ?: throw GradleException("KEY_STORE_FILE not set.")
77-
val keystorePassword: String =
78-
System.getenv("KEY_STORE_PASSWORD") ?: throw GradleException("KEY_STORE_PASSWORD not set")
79-
val keyAlias: String =
80-
System.getenv("KEY_ALIAS") ?: throw GradleException("KEY_ALIAS not set")
81-
val keyPassword: String =
82-
System.getenv("KEY_PASSWORD") ?: throw GradleException("KEY_PASSWORD not set")
83-
84-
// Use file helper to ensure correct path
85-
val localKeystore = rootProject.file("app/mLauncher.jks")
86-
val ciKeystore = layout.buildDirectory.file("temp-keystore.jks").get().asFile
87-
88-
val keystoreFile = when {
89-
localKeystore.exists() -> localKeystore
90-
else -> ciKeystore
91-
}
92-
93-
if (!keystoreFile.exists()) {
94-
keystoreFile.parentFile.mkdirs()
95-
96-
val bytes = Base64.getDecoder().decode(keystoreB64)
97-
98-
if (bytes.size < 1024) {
99-
throw GradleException("Decoded keystore is too small (${bytes.size} bytes)")
100-
}
101-
102-
keystoreFile.writeBytes(bytes)
103-
}
73+
create("release") {
74+
val keystoreFile = rootProject.file("app/mLauncher.jks")
10475

105-
println("Using keystore: ${keystoreFile.absolutePath} (${keystoreFile.length()} bytes)")
76+
println("Using keystore: ${keystoreFile.absolutePath} (${keystoreFile.length()} bytes)")
10677

107-
create("release") {
10878
storeFile = keystoreFile
109-
storePassword = keystorePassword
110-
this.keyAlias = keyAlias
111-
this.keyPassword = keyPassword
79+
storePassword = System.getenv("KEY_STORE_PASSWORD")
80+
?: error("KEY_STORE_PASSWORD not set")
81+
keyAlias = System.getenv("KEY_ALIAS")
82+
?: error("KEY_ALIAS not set")
83+
keyPassword = System.getenv("KEY_PASSWORD")
84+
?: error("KEY_PASSWORD not set")
11285
}
11386
}
11487

0 commit comments

Comments
 (0)