Redo versioning

This commit is contained in:
tibs 2022-04-06 08:51:41 -04:00
parent 8f042e20cc
commit 24174cb64d
Signed by untrusted user who does not match committer: tibs
GPG key ID: 047833989F50F88F

View file

@ -8,7 +8,7 @@ sourceCompatibility = '16'
targetCompatibility = '16' targetCompatibility = '16'
archivesBaseName = project.archives_base_name archivesBaseName = project.archives_base_name
version = "${project.mod_version}${getVersionMetadata()}" version = "${project.mod_version}+${getMetadata()}"
group = project.maven_group group = project.maven_group
repositories { repositories {
@ -69,18 +69,20 @@ jar {
} }
} }
def getVersionMetadata() { def getMetadata() {
def build_id = System.getenv("GITHUB_RUN_NUMBER") def build_id = System.getenv("GITHUB_RUN_NUMBER")
def workflow_id = System.getenv("GITHUB_WORKFLOW") def workflow_id = System.getenv("GITHUB_WORKFLOW")
// CI builds only def metadata = project.minecraft_version
// Release builds only
if (workflow_id == "build-release") { if (workflow_id == "build-release") {
return "+${project.minecraft_version}" return metadata
} else if (build_id != null) {
return "+build.${build_id}"
} }
if (grgit != null) { if (build_id != null) {
metadata += "-build.${build_id}"
} else if (grgit != null) {
def head = grgit.head() def head = grgit.head()
def id = head.abbreviatedId def id = head.abbreviatedId
@ -89,6 +91,8 @@ def getVersionMetadata() {
id += "-dirty" id += "-dirty"
} }
return "+rev.${id}" metadata += "-${id}"
} }
return metadata
} }