Skip to content

Commit

Permalink
Include last commit message to dev builds publications
Browse files Browse the repository at this point in the history
  • Loading branch information
OliverSchlueter committed Oct 20, 2024
1 parent c4cd991 commit c085723
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,20 @@ fun getCurrentCommitHash(): String {
}
}

fun getLastCommitMessage(): String {
val process = ProcessBuilder("git", "log", "-1", "--pretty=%B").start()
val reader = BufferedReader(InputStreamReader(process.inputStream))
val commitMessage = reader.readLine()
reader.close()
process.waitFor()
if (process.exitValue() == 0) {
println("Commit message: $commitMessage")
return commitMessage ?: ""
} else {
throw IllegalStateException("Failed to retrieve the commit message.")
}
}

hangarPublish {
publications.register("plugin") {
version = project.version as String
Expand All @@ -205,6 +219,8 @@ hangarPublish {
platformVersions.set(supportedVersions)
}
}

changelog = getLastCommitMessage()
}
}

Expand All @@ -216,4 +232,6 @@ modrinth {
uploadFile.set(file("build/libs/${project.name}-${project.version}.jar"))
gameVersions.addAll(supportedVersions)
loaders.add("paper")
loaders.add("folia")
changelog.set(getLastCommitMessage())
}

0 comments on commit c085723

Please sign in to comment.