aboutsummaryrefslogtreecommitdiff
path: root/buildSrc/src/main/kotlin/neubs/versioning.kt
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-04-12 14:32:41 +0200
committerGitHub <noreply@github.com>2024-04-12 14:32:41 +0200
commitafd3f0f861ebe7f8957eb6abc6e19f92c7b5896a (patch)
tree0e7990ed1e7083dd4da5f90a842d0122919f8c7c /buildSrc/src/main/kotlin/neubs/versioning.kt
parenta4a1c15a0b0de01e862c0f11882b45fee2c0cca7 (diff)
downloadNotEnoughUpdates-afd3f0f861ebe7f8957eb6abc6e19f92c7b5896a.tar.gz
NotEnoughUpdates-afd3f0f861ebe7f8957eb6abc6e19f92c7b5896a.tar.bz2
NotEnoughUpdates-afd3f0f861ebe7f8957eb6abc6e19f92c7b5896a.zip
Add in-game updater (#1050)
Co-authored-by: IRONM00N <64110067+IRONM00N@users.noreply.github.com>
Diffstat (limited to 'buildSrc/src/main/kotlin/neubs/versioning.kt')
-rw-r--r--buildSrc/src/main/kotlin/neubs/versioning.kt17
1 files changed, 13 insertions, 4 deletions
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<String>()
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
}