plugins { id 'idea' id 'eclipse' id 'fabric-loom' version "${loom_version}" id 'maven-publish' id "com.modrinth.minotaur" version "2.+" id "com.matthewprenger.cursegradle" version "1.4.0" } 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 -> def line = gitLine.substring(1, gitLine.length() - 1) 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 issue links 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" } println "Changelog since $lastTag:\n$changelog" return changelog } task changelog() { doLast { new File(projectDir, "CHANGES.md").text = generateChangelog() } } modrinth { def changes = new File(projectDir, "CHANGES.md") if (changes.exists()) { changes = changes.getText('UTF-8') } else { changes = "" } def modrinth_token = new File(projectDir, "../MODRINTH_TOKEN") if (modrinth_token.exists()) { modrinth_token = modrinth_token.text } else { modrinth_token = "" } def slurper = new groovy.json.JsonSlurper() token = modrinth_token projectId = project.archives_base_name versionNumber = project.mod_version versionType = project.release_channel uploadFile = remapJar gameVersions = slurper.parseText(project.modrinth_versions) loaders = ["fabric"] changelog = changes dependencies { required.project "fabric-api" } debugMode = false } curseforge { def slurper = new groovy.json.JsonSlurper() apiKey = new File(projectDir, "../CURSEFORGE_TOKEN") if (apiKey.exists()) { apiKey = apiKey.text } else { apiKey = "" } def changes = new File(projectDir, "CHANGES.md") if (changes.exists()) { changes = changes.getText('UTF-8') } else { changes = "" } project { id = '495191' changelogType = 'markdown' changelog = changes releaseType = project.release_channel def versions = slurper.parseText(project.modrinth_versions); def latestVersion = '' for (v in versions) { addGameVersion v latestVersion = "[$v]" } addGameVersion 'Fabric' addGameVersion 'Java 17' relations { requiredDependency 'fabric-api' } mainArtifact(remapJar) { displayName = "$project.archives_base_name-$project.version $latestVersion" } afterEvaluate { mainArtifact(remapJar.outputs) } } options { debug = false forgeGradleIntegration = false } }