Skip to content

Commit 25f113e

Browse files
committed
Try to fix publication and versioning
1 parent 3ccc1aa commit 25f113e

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

.github/workflows/publish.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: Java CI
33
on:
44
release:
55
types: [ published ]
6+
workflow_dispatch
67

78
jobs:
89
build:

build.gradle.kts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@ plugins {
77
id("com.diffplug.spotless") version "6.1.2"
88
}
99

10-
group = "de.bluecolored.bluemap.api"
11-
12-
val apiVersion: String by project
13-
version = apiVersion
14-
1510
fun String.runCommand(): String = ProcessBuilder(split("\\s(?=(?:[^'\"`]*(['\"`])[^'\"`]*\\1)*[^'\"`]*$)".toRegex()))
1611
.directory(projectDir)
1712
.redirectOutput(ProcessBuilder.Redirect.PIPE)
@@ -28,8 +23,18 @@ fun String.runCommand(): String = ProcessBuilder(split("\\s(?=(?:[^'\"`]*(['\"`]
2823

2924
val gitHash = "git rev-parse --verify HEAD".runCommand()
3025
val clean = "git status --porcelain".runCommand().isEmpty()
26+
val lastTag = "git describe --tags --abbrev=0".runCommand()
27+
val lastVersion = lastTag.substring(1) // remove the leading 'v'
28+
val commits = "git rev-list --count $lastTag..HEAD".runCommand()
3129
println("Git hash: $gitHash" + if (clean) "" else " (dirty)")
3230

31+
group = "de.bluecolored.bluemap.api"
32+
version = lastVersion +
33+
(if (commits == "0") "" else "-$commits") +
34+
(if (clean) "" else "-dirty")
35+
36+
println("Version: $version")
37+
3338
val javaTarget = 11
3439
java {
3540
sourceCompatibility = JavaVersion.toVersion(javaTarget)
@@ -105,7 +110,7 @@ publishing {
105110
publications {
106111
register<MavenPublication>("gpr") {
107112
from(components["java"])
108-
artifactId = "BlueMapAPI"
113+
artifactId = "bluemap_api"
109114
}
110115
}
111116
}

gradle.properties

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
org.gradle.jvmargs=-Xmx3G
22
org.gradle.daemon=false
3-
4-
apiVersion=2.0.0

0 commit comments

Comments
 (0)