From acaec83cae06cb2aa9afdd9226d4b4e38797389d Mon Sep 17 00:00:00 2001 From: Danny Baumann Date: Fri, 12 Jul 2024 07:53:39 +0200 Subject: [PATCH] Add release signing infrastructure --- .gitignore | 1 + app/build.gradle.kts | 26 ++++++++++++++++++++++++-- wear/build.gradle.kts | 26 +++++++++++++++++++++++++- 3 files changed, 50 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index a5b7298..4ea2b83 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ .externalNativeBuild .cxx local.properties +signing.properties diff --git a/app/build.gradle.kts b/app/build.gradle.kts index aa9b121..1dfdf53 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -14,6 +14,8 @@ * If not, see . */ +import java.util.Properties + plugins { alias(libs.plugins.android.application) alias(libs.plugins.kotlin.android) @@ -52,6 +54,21 @@ android { buildConfig = true } + signingConfigs { + create("release") { + val props = Properties().apply { + val propsFile = File("signing.properties") + if (propsFile.exists()) { + load(propsFile.reader()) + } + } + storeFile = props.getProperty("storeFilePath")?.let { File(it) } + storePassword = props.getProperty("storePassword") + keyPassword = props.getProperty("keyPassword") + keyAlias = props.getProperty("keyAlias") + } + } + buildTypes { release { isMinifyEnabled = true @@ -59,8 +76,13 @@ android { getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" ) - // FIXME - signingConfig = signingConfigs.getByName("debug") + val signing = signingConfigs.findByName("release") + if (signing != null && signing.storeFile != null && signing.storePassword != null && signing.keyPassword != null && signing.keyAlias != null) { + signingConfig = signing + } else { + println("Release signing config not available, falling back to debug config") + signingConfig = signingConfigs.getByName("debug") + } } debug { isDebuggable = true diff --git a/wear/build.gradle.kts b/wear/build.gradle.kts index 09a093e..2eb04c6 100644 --- a/wear/build.gradle.kts +++ b/wear/build.gradle.kts @@ -9,6 +9,8 @@ * You should have received a copy of the GNU General Public License along with this program. If not, see . */ +import java.util.Properties + plugins { alias(libs.plugins.android.application) alias(libs.plugins.kotlin.android) @@ -32,6 +34,21 @@ android { compose = true } + signingConfigs { + create("release") { + val props = Properties().apply { + val propsFile = File("signing.properties") + if (propsFile.exists()) { + load(propsFile.reader()) + } + } + storeFile = props.getProperty("storeFilePath")?.let { File(it) } + storePassword = props.getProperty("storePassword") + keyPassword = props.getProperty("keyPassword") + keyAlias = props.getProperty("keyAlias") + } + } + buildTypes { release { isMinifyEnabled = true @@ -39,6 +56,13 @@ android { getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" ) + val signing = signingConfigs.findByName("release") + if (signing != null && signing.storeFile != null && signing.storePassword != null && signing.keyPassword != null && signing.keyAlias != null) { + signingConfig = signing + } else { + println("Release signing config not available, falling back to debug config") + signingConfig = signingConfigs.getByName("debug") + } } } compileOptions { @@ -64,4 +88,4 @@ dependencies { implementation(libs.androidx.wear.compose.material) implementation(libs.androidx.wear.tooling.preview) implementation(project(":wearapi")) -} \ No newline at end of file +}