Skip to content

Commit

Permalink
Try new definition of VERSION_NAME from Git
Browse files Browse the repository at this point in the history
  • Loading branch information
MGaetan89 committed Jun 19, 2024
1 parent b96d950 commit dd88fee
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions pillarbox-player/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,8 @@ android {
}

release {
val versionName = ByteArrayOutputStream().use { stream ->
exec {
commandLine = listOf("git", "describe", "--tags", "--abbrev=0")
standardOutput = stream
}
stream.toString(Charsets.UTF_8).trim()
}
val latestTagHash = execCommand("git", "rev-list", "--tags", "--max-count=1")
val versionName = execCommand("git", "describe", "--tags", "$latestTagHash")

buildConfigField("String", "VERSION_NAME", "\"${versionName}\"")
}
Expand Down Expand Up @@ -85,3 +80,13 @@ dependencies {
androidTestRuntimeOnly(libs.kotlinx.coroutines.android)
androidTestImplementation(libs.mockk)
}

private fun execCommand(vararg commandSegments: String): String {
return ByteArrayOutputStream().use { stream ->
exec {
commandLine = commandSegments.toList()
standardOutput = stream
}
stream.toString(Charsets.UTF_8).trim()
}
}

0 comments on commit dd88fee

Please sign in to comment.