From b517866731a3f27fc2cd82fe7060ab5ee3134bef Mon Sep 17 00:00:00 2001 From: Jacker Date: Wed, 24 Jan 2024 18:43:31 +0200 Subject: [PATCH] gradle: have sensible defaults for the version information --- .github/workflows/build.yaml | 2 +- build.gradle | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index c2dccf5..ad5b501 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -32,7 +32,7 @@ jobs: uses: android-actions/setup-android@v3 - name: Build and publish - run: ./gradlew publish --no-daemon + run: ./gradlew publish --no-daemon --info env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/build.gradle b/build.gradle index 2ded6fd..cb3eab9 100644 --- a/build.gradle +++ b/build.gradle @@ -14,14 +14,16 @@ buildscript { } def parseGitVersion() { - def major = 0 - def minor = 0 + def major = 1 + def minor = 2 def patch = 0 - def postfix = 'UNKNOWN' + def postfix = '-UNKNOWN' def hash = '' def output = 'git describe --long --tags --dirty --always'.execute().text.trim() + project.logger.info("Ran git describe with the output: {}", output) (output =~ /^v(\d+)\.(\d+)\.(\d+)-(\d+)-(\w+)/).each { match, majorVal, minorVal, patchVal, commitVal, hashVal -> if (output.toLowerCase().endsWith('-dirty')) { + patchVal = (patchVal as int + 1) as String postfix = '-DIRTY' } else if(commit as int > 0) { patchVal = (patchVal as int + 1) as String @@ -35,7 +37,9 @@ def parseGitVersion() { patch = patchVal as int hash = hashVal } - return [version: "${major}.${minor}.${patch}${postfix}", hash: hash] + def outputHash = [version: "${major}.${minor}.${patch}${postfix}", hash: hash] + project.logger.info("Parsed version: {}", outputHash.version) + return outputHash } def versionInfo = parseGitVersion() @@ -53,4 +57,4 @@ subprojects { Project ch -> tasks.register('clean', Delete) { delete rootProject.buildDir -} \ No newline at end of file +}