From 564a5f1e4162ee0fb1453e7a07ab601fbe458ba9 Mon Sep 17 00:00:00 2001 From: ah-OOG-ah <75745146+ah-OOG-ah@users.noreply.github.com> Date: Wed, 30 Oct 2024 18:50:19 -0400 Subject: [PATCH] Add altered versioning If there's a tag or the flag is passed, just uses the set version. Otherwise, it adds the commit hash and -dirty if applicable. --- build.gradle | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/build.gradle b/build.gradle index e57a16f9..ba6aa1b6 100644 --- a/build.gradle +++ b/build.gradle @@ -3,3 +3,25 @@ plugins { id 'com.gtnewhorizons.gtnhconvention' } + +// The planned name of the next release +def NEXT_VERSION = "2.6.1" +version = NEXT_VERSION + +// Append to the version as needed. If the variables look a bit strange, that's because they are - +// git-version doesn't expose a ton of useful functions, we need to extract them indirectly. + +// If we have a clean tag (or manually specified), this is a production release. +// No need for the commit hash! +def details = versionDetails() +def isPlainTag = details.getCommitDistance() == 0 +def noCommitHash = providers.gradleProperty("noCommitHash").isPresent() +if (!isPlainTag && !noCommitHash) { + version += "-" + details.gitHash +} + +// If we have uncommitted changes, say so. +def isDirty = gitVersion().endsWith(".dirty") +if (isDirty && !noCommitHash) { + version += "-dirty" +}