Skip to content

Commit

Permalink
ci: support custom app version for fdroid [WPB-10569] (#3312)
Browse files Browse the repository at this point in the history
Co-authored-by: yamilmedina <yamilmedina@users.noreply.github.com>
  • Loading branch information
MohamadJaara and yamilmedina authored Aug 13, 2024
1 parent 443db9d commit 81e9652
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,21 @@ import java.time.LocalDateTime
*/
class Versionizer(private val localDateTime: LocalDateTime = LocalDateTime.now()) {

val versionCode = generateVersionCode()
// get version from app/version.txt otherwise use the current date
val versionCode = readFromInternalFile() ?: generateVersionCode()

// get version from app/version.txt otherwise use the current date the file have the following format
// VersionCode: $$VERCODE$$\n
// the file is added by CI tp sync build version between store and fdroid
private fun readFromInternalFile(): Int? {
val file = java.io.File("app/version.txt")
if (file.exists()) {
val lines = file.readLines()
val versionCode = lines.find { it.startsWith("VersionCode:") }?.substringAfter(":")?.trim()
return versionCode?.toIntOrNull()
}
return null
}

private fun generateVersionCode(): Int {
return if (localDateTime <= V2_DATE_OFFSET) {
Expand Down
6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ buildscript {
google()
mavenCentral()
maven(url = "https://oss.sonatype.org/content/repositories/snapshots")
maven(url ="https://plugins.gradle.org/m2/")
maven(url = "https://plugins.gradle.org/m2/")
}
dependencies {
classpath(libs.hilt.gradlePlugin)
Expand All @@ -32,7 +32,7 @@ buildscript {
.lowercase()
.contains("fdroid")

if (fdroidBuild) {
if (fdroidBuild) {
println("Not including gms")
} else {
println("Including gms")
Expand All @@ -46,7 +46,7 @@ allprojects {
repositories {
google()
mavenCentral()
maven { url = java.net.URI("https://jitpack.io") }
maven(url = "https://jitpack.io")
maven(url = "https://oss.sonatype.org/content/repositories/snapshots")
}
}
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ kotlin.code.style=official

# Support KMP Gradle Composite Builds - See https://youtrack.jetbrains.com/issue/KT-52172/
kotlin.mpp.import.enableKgpDependencyResolution=true
org.gradle.logging.level=QUIET
2 changes: 1 addition & 1 deletion kalium
Submodule kalium updated 1 files
+1 −0 gradle.properties

0 comments on commit 81e9652

Please sign in to comment.