diff --git a/build.gradle.kts b/build.gradle.kts index 58265fa..6002203 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -11,7 +11,7 @@ plugins { } group = "me.lojosho" -version = "0.5.1" +version = "0.5.2-${getGitCommitHash()}" allprojects { apply(plugin = "java") @@ -304,4 +304,16 @@ class PublishData(private val project: Project) { fun append(name: String, appendCommit: Boolean, commitHash: String): String = name.plus(append).plus(if (appendCommit && addCommit) "-".plus(commitHash) else "") } +} + +fun getGitCommitHash(): String { + return try { + val process = ProcessBuilder("git", "rev-parse", "--short", "HEAD") + .redirectErrorStream(true) + .start() + + process.inputStream.bufferedReader().use { it.readLine().trim() } + } catch (e: Exception) { + "unknown" // Fallback if Git is not available or an error occurs + } } \ No newline at end of file