Skip to content

Commit

Permalink
Sign release apk only if keystore.properties is present
Browse files Browse the repository at this point in the history
Signed-off-by: Patryk Miś <[email protected]>
  • Loading branch information
PatrykMis committed Nov 28, 2023
1 parent 639dd00 commit 5aca95c
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ plugins {
alias(libs.plugins.dagger)
}

val keystorePropertiesFile = rootProject.file("keystore.properties")
val useKeystoreProperties = keystorePropertiesFile.canRead()

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
Expand All @@ -43,13 +46,15 @@ android {
compileSdk = 34
buildToolsVersion = "34.0.0"

signingConfigs {
create("release") {
properties(name = "keystore.properties") { properties ->
storeFile = rootProject.file(properties.getProperty("storeFile"))
storePassword = properties.getProperty("storePassword")
keyAlias = properties.getProperty("keyAlias")
keyPassword = properties.getProperty("keyPassword")
if (useKeystoreProperties) {
signingConfigs {
create("release") {
properties(name = "keystore.properties") { properties ->
storeFile = rootProject.file(properties.getProperty("storeFile"))
storePassword = properties.getProperty("storePassword")
keyAlias = properties.getProperty("keyAlias")
keyPassword = properties.getProperty("keyPassword")
}
}
}
}
Expand All @@ -75,7 +80,9 @@ android {
release {
isMinifyEnabled = false

signingConfig = signingConfigs.getByName("release")
if (useKeystoreProperties) {
signingConfig = signingConfigs.getByName("release")
}
}

debug {
Expand Down

0 comments on commit 5aca95c

Please sign in to comment.