98 lines
No EOL
3.2 KiB
Groovy
98 lines
No EOL
3.2 KiB
Groovy
plugins {
|
|
id 'idea'
|
|
id 'eclipse'
|
|
id 'fabric-loom' version "${loom_version}"
|
|
id 'maven-publish'
|
|
id "com.modrinth.minotaur" version "2.+"
|
|
}
|
|
|
|
apply from: "bclib.gradle"
|
|
|
|
//from https://lowcarbrob.medium.com/android-pro-tip-generating-your-apps-changelog-from-git-inside-build-gradle-19a07533eec4
|
|
String generateChangelog() {
|
|
println "Assembeling Changelog ..."
|
|
def lastTag = "git describe --tags --abbrev=0".execute().text.trim()
|
|
def gitLogCmd = "git log $lastTag..HEAD --oneline --no-merges --pretty=format:\"%s\"".execute().text.trim()
|
|
|
|
def features = ""
|
|
def fixes = ""
|
|
def changes = ""
|
|
gitLogCmd.eachLine { gitLine ->
|
|
//Remove surrounding quotation marks generated by the git log command
|
|
def line = gitLine.substring(1, gitLine.length() - 1)
|
|
//Escape backslashes
|
|
//line = line.replaceAll(/(\\)/, "\\/")
|
|
//Escape quotation marks
|
|
//line = line.replaceAll('"', '\\\\"')
|
|
// if (line.toLowerCase().startsWith("[Version]"))
|
|
|
|
if (line.trim().startsWith("[")) {
|
|
def sline = line.split("]", 2)
|
|
if (sline.length == 2) {
|
|
def type = sline[0].trim().toLowerCase().substring(1)
|
|
def comment = sline[1].trim()
|
|
|
|
//filter out links to issues
|
|
if (comment.contains("(")) {
|
|
def cline = comment.split("\\(", 2)
|
|
if (cline.length == 2 && cline[1].contains("#")) {
|
|
comment = cline[0].trim()
|
|
}
|
|
}
|
|
|
|
if (type == "fix" || type == "fixes" || type == "fixed") {
|
|
fixes += "- $comment \n"
|
|
} else if (type == "feature" || type == "features") {
|
|
features += "- $comment \n"
|
|
} else if (type == "change" || type == "changes" || type == "changed") {
|
|
changes += "- $comment \n"
|
|
} else {
|
|
println "Unknown Type: $type ($line)"
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
def changelog = ""
|
|
if (!features.isEmpty()) {
|
|
changelog += "#### Features\n"
|
|
changelog += features.trim()
|
|
changelog += "\n\n"
|
|
}
|
|
if (!changes.isEmpty()) {
|
|
changelog += "#### Changes\n"
|
|
changelog += changes.trim()
|
|
changelog += "\n\n"
|
|
}
|
|
if (!fixes.isEmpty()) {
|
|
changelog += "#### Fixes\n"
|
|
changelog += fixes.trim()
|
|
changelog += "\n\n"
|
|
}
|
|
|
|
|
|
//Useful log so you can see what was generated in the Gradle output
|
|
println "Changelog since $lastTag:\n$changelog"
|
|
return changelog
|
|
}
|
|
|
|
task changelog() {
|
|
doLast {
|
|
new File(projectDir, "CHANGES.md").text = generateChangelog()
|
|
}
|
|
}
|
|
|
|
modrinth {
|
|
token = new File(projectDir, "../MODRINTH_TOKEN").text
|
|
projectId = "bclib"
|
|
versionNumber = "$mod_version"
|
|
versionType = "release" // This is the default -- can also be `beta` or `alpha`
|
|
uploadFile = remapJar
|
|
gameVersions = ["1.19", "1.19.1", "1.19.2"]
|
|
loaders = ["fabric"]
|
|
changelog = new File(projectDir, "CHANGES.md").getText('UTF-8')
|
|
dependencies {
|
|
required.project "fabric-api"
|
|
}
|
|
debugMode = false
|
|
} |