Skip to content

Commit

Permalink
signing key for preview
Browse files Browse the repository at this point in the history
  • Loading branch information
cuong-tran committed Jul 8, 2024
1 parent 0496c60 commit 457af3d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ CHANGELOG.md
/captures
build.sh
/app/src/main/assets/client_secrets.json
*.jks
26 changes: 25 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import mihon.buildlogic.getBuildTime
import mihon.buildlogic.getCommitCount
import mihon.buildlogic.getGitSha
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.io.FileInputStream
import java.util.Properties

plugins {
id("mihon.android.application")
Expand Down Expand Up @@ -53,6 +55,15 @@ android {
}
}

signingConfigs {
create("preview") {
storeFile = rootProject.file(readPropertyFromLocalProperties("keystore") ?: "keystore.jks")
storePassword = readPropertyFromLocalProperties("storePassword")
keyAlias = readPropertyFromLocalProperties("keyAlias")
keyPassword = readPropertyFromLocalProperties("keyPassword")
}
}

buildTypes {
named("debug") {
versionNameSuffix = "-${getCommitCount()}"
Expand All @@ -78,7 +89,7 @@ android {
matchingFallbacks.add("release")
versionNameSuffix = "-${getCommitCount()}"
applicationIdSuffix = ".beta"
signingConfig = signingConfigs.getByName("debug")
signingConfig = signingConfigs.getByName("preview")
}
create("benchmark") {
initWith(getByName("release"))
Expand Down Expand Up @@ -344,3 +355,16 @@ buildscript {
classpath(kotlinx.gradle)
}
}

// Config local store's signing key
fun readPropertyFromLocalProperties(propertyName: String): String? {
val localPropertiesFile = rootProject.file("local.properties")
if (localPropertiesFile.exists()) {
val properties = Properties()
FileInputStream(localPropertiesFile).use { inputStream ->
properties.load(inputStream)
}
return properties.getProperty(propertyName)
}
return null // Property not found
}

0 comments on commit 457af3d

Please sign in to comment.