Skip to content
This repository was archived by the owner on Jan 25, 2024. It is now read-only.

Commit 333b097

Browse files
committed
Include git head in version number
1 parent 24f5934 commit 333b097

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

build.gradle

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
plugins {
22
id 'java'
33
id 'com.github.johnrengelman.shadow' version '7.1.2'
4+
id 'org.ajoberstar.grgit' version '5.0.0'
45
}
56

67
group 'net.william278'
7-
version '2.0'
8+
version "2.0-${versionMetadata()}"
89

910
repositories {
1011
mavenCentral()
@@ -37,4 +38,12 @@ jar {
3738

3839
test {
3940
useJUnitPlatform()
41+
}
42+
43+
@SuppressWarnings('GrMethodMayBeStatic')
44+
def versionMetadata() {
45+
if (grgit == null) {
46+
return System.getenv("GITHUB_RUN_NUMBER") ? 'build.' + System.getenv("GITHUB_RUN_NUMBER") : 'unknown'
47+
}
48+
return grgit.head().abbreviatedId + (grgit.status().clean ? '' : '-indev')
4049
}

0 commit comments

Comments
 (0)