fix: nightly versioning

This commit is contained in:
Zane Schepke 2024-07-27 22:56:56 -04:00
parent 4dd8241fa1
commit a9a49e3421
3 changed files with 11 additions and 22 deletions

View File

@ -21,8 +21,8 @@ android {
applicationId = Constants.APP_ID applicationId = Constants.APP_ID
minSdk = Constants.MIN_SDK minSdk = Constants.MIN_SDK
targetSdk = Constants.TARGET_SDK targetSdk = Constants.TARGET_SDK
versionCode = versionCode() versionCode = Constants.VERSION_CODE
versionName = versionName() versionName = Constants.VERSION_NAME
ksp { arg("room.schemaLocation", "$projectDir/schemas") } ksp { arg("room.schemaLocation", "$projectDir/schemas") }
@ -67,12 +67,14 @@ android {
getDefaultProguardFile("proguard-android-optimize.txt"), getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro", "proguard-rules.pro",
) )
signingConfig = signingConfigs.getByName(signingConfigName()) signingConfig = signingConfigs.getByName(Constants.RELEASE)
} }
debug { isDebuggable = true } debug { isDebuggable = true }
create("nightly") { create(Constants.NIGHTLY) {
initWith(getByName("release")) initWith(getByName("release"))
defaultConfig.versionName = nightlyVersionName()
defaultConfig.versionCode = nightlyVersionCode()
} }
} }
flavorDimensions.add(Constants.TYPE) flavorDimensions.add(Constants.TYPE)
@ -183,10 +185,10 @@ dependencies {
implementation(libs.androidx.core.splashscreen) implementation(libs.androidx.core.splashscreen)
} }
fun versionCode() : Int { fun nightlyVersionCode() : Int {
return if(!isNightlyBuild()) Constants.VERSION_CODE else Constants.VERSION_CODE + Constants.NIGHTLY_CODE return Constants.VERSION_CODE + Constants.NIGHTLY_CODE
} }
fun versionName() : String { fun nightlyVersionName() : String {
return if(!isNightlyBuild()) Constants.VERSION_NAME else Constants.VERSION_NAME + "-${grgitService.service.get().grgit.head().abbreviatedId}" return Constants.VERSION_NAME + "-${grgitService.service.get().grgit.head().abbreviatedId}"
} }

View File

@ -13,6 +13,7 @@ object Constants {
const val KEY_STORE_PATH_VAR = "KEY_STORE_PATH" const val KEY_STORE_PATH_VAR = "KEY_STORE_PATH"
const val RELEASE = "release" const val RELEASE = "release"
const val NIGHTLY = "nightly"
const val DEBUG = "debug" const val DEBUG = "debug"
const val TYPE = "type" const val TYPE = "type"

View File

@ -39,16 +39,6 @@ fun Project.isGeneralFlavor(gradle: Gradle): Boolean {
return getCurrentFlavor(gradle) == "general" return getCurrentFlavor(gradle) == "general"
} }
fun Project.isReleaseBuild(): Boolean {
return (gradle.startParameter.taskNames.size > 0 &&
gradle.startParameter.taskNames[0].contains(
"Release",
))
}
fun Project.isNightlyBuild(): Boolean {
return gradle.startParameter.taskNames.contains("Nightly")
}
fun Project.getSigningProperties() : Properties { fun Project.getSigningProperties() : Properties {
return Properties().apply { return Properties().apply {
@ -80,10 +70,6 @@ fun Project.getSigningProperty(property: String) : String {
) )
} }
fun Project.signingConfigName() : String {
return if(getSigningProperty(Constants.KEY_PASS_VAR).isBlank()) Constants.DEBUG else Constants.RELEASE
}