From a43cc4108b4742fa61c7f9fbeb4ad725c3190a3d Mon Sep 17 00:00:00 2001 From: William Date: Thu, 13 Jun 2024 23:56:56 +0100 Subject: [PATCH] build: update versioning --- build.gradle | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/build.gradle b/build.gradle index 9f864cd..2da9b06 100644 --- a/build.gradle +++ b/build.gradle @@ -189,15 +189,20 @@ logger.lifecycle("Building Uniform ${version} by William278") @SuppressWarnings('GrMethodMayBeStatic') def versionMetadata() { - // Get if there is a tag for this commit + // Require grgit + if (grgit == null) { + return '-unknown' + } + + // If unclean, return the last commit hash with -indev + if (!grgit.status().clean) { + return '-' + grgit.head().abbreviatedId + '-indev' + } + + // Otherwise if this matches a tag, return nothing def tag = grgit.tag.list().find { it.commit.id == grgit.head().id } if (tag != null) { return '' } - - // Otherwise, get the last commit hash and if it's a clean head - if (grgit == null) { - return '-' + System.getenv("GITHUB_RUN_NUMBER") ? 'build.' + System.getenv("GITHUB_RUN_NUMBER") : 'unknown' - } - return '-' + grgit.head().abbreviatedId + (grgit.status().clean ? '' : '-indev') + return '-' + grgit.head().abbreviatedId } \ No newline at end of file