From afd3f0f861ebe7f8957eb6abc6e19f92c7b5896a Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Fri, 12 Apr 2024 14:32:41 +0200 Subject: Add in-game updater (#1050) Co-authored-by: IRONM00N <64110067+IRONM00N@users.noreply.github.com> --- buildSrc/src/main/kotlin/neubs/versioning.kt | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'buildSrc/src/main/kotlin/neubs/versioning.kt') diff --git a/buildSrc/src/main/kotlin/neubs/versioning.kt b/buildSrc/src/main/kotlin/neubs/versioning.kt index 9294e164..24e6cc05 100644 --- a/buildSrc/src/main/kotlin/neubs/versioning.kt +++ b/buildSrc/src/main/kotlin/neubs/versioning.kt @@ -22,15 +22,24 @@ package neubs import org.gradle.api.Project import java.io.ByteArrayOutputStream -fun Project.setVersionFromEnvironment(baseVersion: String) { +fun Project.setVersionFromEnvironment(): String { + val baseVersion = run { + val baos = ByteArrayOutputStream() + exec { + commandLine("git", "describe", "--tags", "--abbrev=0") + standardOutput = baos + isIgnoreExitValue = true + } + (baos.toByteArray()).decodeToString().trim() + } val buildExtra = mutableListOf() val buildVersion = properties["BUILD_VERSION"] as? String if (buildVersion != null) buildExtra.add(buildVersion) - if (System.getenv("CI") == "true") buildExtra.add("ci") + if (System.getenv("CI") == "true" && System.getenv("NEU_RELEASE") != "true") buildExtra.add("ci") val stdout = ByteArrayOutputStream() val execResult = exec { - commandLine("git", "describe", "--always", "--first-parent", "--abbrev=7") + commandLine("git", "rev-parse", "--short", "HEAD") standardOutput = stdout isIgnoreExitValue = true } @@ -49,6 +58,6 @@ fun Project.setVersionFromEnvironment(baseVersion: String) { } version = baseVersion + (if (buildExtra.isEmpty()) "" else buildExtra.joinToString(prefix = "+", separator = ".")) - + return baseVersion } -- cgit