Try to fix publication and versioning

This commit is contained in:
Lukas Rieger (Blue) 2022-08-01 23:10:19 +02:00
parent 3ccc1aad81
commit 25f113ebdb
No known key found for this signature in database
GPG Key ID: 2D09EC5ED2687FF2
3 changed files with 12 additions and 8 deletions

View File

@ -3,6 +3,7 @@ name: Java CI
on:
release:
types: [ published ]
workflow_dispatch
jobs:
build:

View File

@ -7,11 +7,6 @@ plugins {
id("com.diffplug.spotless") version "6.1.2"
}
group = "de.bluecolored.bluemap.api"
val apiVersion: String by project
version = apiVersion
fun String.runCommand(): String = ProcessBuilder(split("\\s(?=(?:[^'\"`]*(['\"`])[^'\"`]*\\1)*[^'\"`]*$)".toRegex()))
.directory(projectDir)
.redirectOutput(ProcessBuilder.Redirect.PIPE)
@ -28,8 +23,18 @@ fun String.runCommand(): String = ProcessBuilder(split("\\s(?=(?:[^'\"`]*(['\"`]
val gitHash = "git rev-parse --verify HEAD".runCommand()
val clean = "git status --porcelain".runCommand().isEmpty()
val lastTag = "git describe --tags --abbrev=0".runCommand()
val lastVersion = lastTag.substring(1) // remove the leading 'v'
val commits = "git rev-list --count $lastTag..HEAD".runCommand()
println("Git hash: $gitHash" + if (clean) "" else " (dirty)")
group = "de.bluecolored.bluemap.api"
version = lastVersion +
(if (commits == "0") "" else "-$commits") +
(if (clean) "" else "-dirty")
println("Version: $version")
val javaTarget = 11
java {
sourceCompatibility = JavaVersion.toVersion(javaTarget)
@ -105,7 +110,7 @@ publishing {
publications {
register<MavenPublication>("gpr") {
from(components["java"])
artifactId = "BlueMapAPI"
artifactId = "bluemap_api"
}
}
}

View File

@ -1,4 +1,2 @@
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
apiVersion=2.0.0