Fix ci versioning 2

This commit is contained in:
Lukas Rieger (Blue) 2022-07-27 12:30:11 +02:00
parent 32269cc012
commit 55dbf38144
No known key found for this signature in database
GPG Key ID: 2D09EC5ED2687FF2

View File

@ -23,17 +23,23 @@ fun String.runCommand(): String = ProcessBuilder(split("\\s(?=(?:[^'\"`]*(['\"`]
val gitHash = "git rev-parse --verify HEAD".runCommand() val gitHash = "git rev-parse --verify HEAD".runCommand()
val clean = "git status --porcelain".runCommand().isEmpty() val clean = "git status --porcelain".runCommand().isEmpty()
val branch = "git branch --show-current".runCommand() val branch = "git rev-parse --abbrev-ref HEAD".runCommand()
val commitCount = "git rev-list --count HEAD".runCommand() val commitCount = "git rev-list --count HEAD".runCommand()
if (branch.isEmpty()) {
throw IllegalStateException("Could not determine branch name")
}
println("Git hash: $gitHash" + if (clean) "" else " (dirty)") println("Git hash: $gitHash" + if (clean) "" else " (dirty)")
println("Branch: $branch")
val releaseProperties = Properties() val releaseProperties = Properties()
releaseProperties.load(file("../release.properties").inputStream()) releaseProperties.load(file("../release.properties").inputStream())
group = "de.bluecolored.bluemap.core" group = "de.bluecolored.bluemap.core"
version = releaseProperties["version"].toString() + ".$commitCount" + version = releaseProperties["version"].toString() + ".$commitCount" +
if (clean) "" else ".dirty" + (if (clean) "" else ".dirty") +
if (branch == "master") "" else "-$branch" (if (branch == "master") "" else "-$branch")
println("Version: $version") println("Version: $version")
val javaTarget = 11 val javaTarget = 11