From a9943253c55081d8c39a6bf54f0a85d6a0e02a46 Mon Sep 17 00:00:00 2001 From: Diar Gegaj Date: Thu, 12 Oct 2023 12:56:35 +0200 Subject: [PATCH] Use keystore properties from github when build is from CI. And load locally when build is not CI. --- app/build.gradle.kts | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index e15e74b..88d39e5 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,3 +1,6 @@ +import java.io.FileInputStream +import java.util.Properties + plugins { id("com.android.application") id("org.jetbrains.kotlin.android") @@ -6,16 +9,30 @@ plugins { id("com.google.gms.google-services") } +val keystoreProperties = Properties() +val keystoreFile = rootProject.file("keystore.properties") + +if (keystoreFile.exists()) { + keystoreProperties.load(FileInputStream(keystoreFile)) +} + android { namespace = "com.diargegaj.recipesharing" compileSdk = 34 signingConfigs { create("release") { - storeFile = file(System.getenv("KEYSTORE_PATH") ?: "") - storePassword = System.getenv("STORE_PASSWORD") - keyAlias = System.getenv("KEY_ALIAS") - keyPassword = System.getenv("KEY_PASSWORD") + if (System.getenv("CI") == "true") { + storeFile = file(System.getenv("KEYSTORE_PATH") ?: "") + storePassword = System.getenv("STORE_PASSWORD") + keyAlias = System.getenv("KEY_ALIAS") + keyPassword = System.getenv("KEY_PASSWORD") + } else { + storeFile = keystoreProperties["storeFile"]?.let { file(it) } + storePassword = keystoreProperties["storePassword"].toString() + keyAlias = keystoreProperties["keyAlias"].toString() + keyPassword = keystoreProperties["keyPassword"].toString() + } } }