From 7cc19c1075e5bd27ed8013d1f6b13c72dcd6ecb7 Mon Sep 17 00:00:00 2001 From: George Powley Date: Wed, 1 May 2024 09:40:51 -0400 Subject: [PATCH] Set java/spark version from git tag (#716) --- .azure-pipelines.yml | 1 + apis/java/build.gradle | 25 ++++++++++++++++++++++++- apis/spark/build.gradle | 25 ++++++++++++++++++++++++- apis/spark3/build.gradle | 25 ++++++++++++++++++++++++- ci/native_libs-linux_osx.yml | 4 ++++ 5 files changed, 77 insertions(+), 3 deletions(-) diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml index d39890443..820005f39 100644 --- a/.azure-pipelines.yml +++ b/.azure-pipelines.yml @@ -111,6 +111,7 @@ stages: unset SYSTEM set +e ci/collect-nativelibs.sh + displayName: 'Collect Native Libraries' - task: ArchiveFiles@2 inputs: diff --git a/apis/java/build.gradle b/apis/java/build.gradle index 403c5bf2c..78c9fada5 100644 --- a/apis/java/build.gradle +++ b/apis/java/build.gradle @@ -6,8 +6,28 @@ plugins { id 'com.github.johnrengelman.shadow' version '4.0.3' } +ext.getVersionName = { -> + def stdout = new ByteArrayOutputStream() + try { + // Try to get the version from git + exec { + commandLine 'git', 'describe', '--tags' + standardOutput = stdout + } + return stdout.toString().trim() + } catch (Exception e1) { + try { + // Try to get the version from a file + return file("../../version.txt").text.trim() + } catch (Exception e2) { + // Version is unknown + return "unknown" + } + } +} + group 'io.tiledb' -version '0.31.0' +version getVersionName() sourceCompatibility = 1.8 targetCompatibility = 1.8 @@ -40,6 +60,9 @@ test { testLogging { showStandardStreams = true } + doLast { + println "\nTileDB-VCF version: ${project.version}" + } } // Helper task containing some path information diff --git a/apis/spark/build.gradle b/apis/spark/build.gradle index 0aed6d242..a30d198a0 100644 --- a/apis/spark/build.gradle +++ b/apis/spark/build.gradle @@ -6,8 +6,28 @@ plugins { id 'com.github.johnrengelman.shadow' version '4.0.3' } +ext.getVersionName = { -> + def stdout = new ByteArrayOutputStream() + try { + // Try to get the version from git + exec { + commandLine 'git', 'describe', '--tags' + standardOutput = stdout + } + return stdout.toString().trim() + } catch (Exception e1) { + try { + // Try to get the version from a file + return file("../../version.txt").text.trim() + } catch (Exception e2) { + // Version is unknown + return "unknown" + } + } +} + group 'io.tiledb' -version '0.31.0' +version getVersionName() sourceCompatibility = 1.8 targetCompatibility = 1.8 @@ -50,6 +70,9 @@ test { testLogging { showStandardStreams = true } + doLast { + println "\nTileDB-VCF version: ${project.version}" + } } shadowJar { diff --git a/apis/spark3/build.gradle b/apis/spark3/build.gradle index 167839bd5..2a535d2a7 100644 --- a/apis/spark3/build.gradle +++ b/apis/spark3/build.gradle @@ -6,8 +6,28 @@ plugins { id 'com.github.johnrengelman.shadow' version '4.0.3' } +ext.getVersionName = { -> + def stdout = new ByteArrayOutputStream() + try { + // Try to get the version from git + exec { + commandLine 'git', 'describe', '--tags' + standardOutput = stdout + } + return stdout.toString().trim() + } catch (Exception e1) { + try { + // Try to get the version from a file + return file("../../version.txt").text.trim() + } catch (Exception e2) { + // Version is unknown + return "unknown" + } + } +} + group 'io.tiledb' -version '0.31.0' +version getVersionName() sourceCompatibility = 1.8 targetCompatibility = 1.8 @@ -50,6 +70,9 @@ test { testLogging { showStandardStreams = true } + doLast { + println "\nTileDB-VCF version: ${project.version}" + } } shadowJar { diff --git a/ci/native_libs-linux_osx.yml b/ci/native_libs-linux_osx.yml index 598f76991..8ef477824 100755 --- a/ci/native_libs-linux_osx.yml +++ b/ci/native_libs-linux_osx.yml @@ -92,6 +92,10 @@ steps: env: { sourceVersion: $(Build.SourceVersion) } displayName: Git Hash 7-digit + - bash: | + git describe --tags > $BUILD_REPOSITORY_LOCALPATH/version.txt + displayName: 'Capture version' + - task: ArchiveFiles@2 inputs: rootFolderOrFile: '$(Build.BinariesDirectory)'