Skip to content

Commit

Permalink
build: add a function to extract the changelog from git commits
Browse files Browse the repository at this point in the history
  • Loading branch information
Angelillo15 committed Dec 26, 2024
1 parent 6d0c5c7 commit 4277775
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,34 @@ modrinth {
System.getenv("MODRINTH_VERSION_TYPE") ?: "release"
}

changelog.set(getChangeLog())
uploadFile.set(tasks.shadowJar.get().archiveFile)
gameVersions.addAll("1.19.4", "1.20.6", "1.21", "1.21.1", "1.21.2", "1.21.3", "1.21.4")
loaders.addAll("paper", "purpur", "velocity")

syncBodyFrom = rootProject.file("README.md").readText()
}

fun getChangeLog(): String {
val currentBranch = grgit.branch.current().name
val remoteBranch = "origin/$currentBranch"

val lastRemoteCommit = grgit.log {
range(remoteBranch, currentBranch)
}.lastOrNull()?.id ?: return "No se encontraron cambios desde el remoto."

val changeLog = grgit.log {
range(lastRemoteCommit, currentBranch)
}

return if (changeLog.isNotEmpty()) {
changeLog.joinToString("\n") { commit ->
"- ${commit.shortMessage} (${commit.id})"
}
} else {
"No changes found."
}
}
tasks.modrinth {
dependsOn(tasks.shadowJar)
dependsOn(tasks.modrinthSyncBody)
Expand Down

0 comments on commit 4277775

Please sign in to comment.