Fix for version increment
This commit is contained in:
parent
def336a033
commit
97bfd73c10
2 changed files with 40 additions and 0 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -31,3 +31,5 @@ run-client/
|
||||||
run-server/
|
run-server/
|
||||||
output/
|
output/
|
||||||
*.log
|
*.log
|
||||||
|
/CHANGES.md
|
||||||
|
/modrinth.json
|
||||||
|
|
38
build.gradle
38
build.gradle
|
@ -146,4 +146,42 @@ curseforge {
|
||||||
debug = false
|
debug = false
|
||||||
forgeGradleIntegration = false
|
forgeGradleIntegration = false
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
task nextVersion() {
|
||||||
|
doLast {
|
||||||
|
def inputFile = new File('modrinth.json')
|
||||||
|
def gameVersions = java.net.URLEncoder.encode(project.modrinth_versions, "UTF-8")
|
||||||
|
new URL("https://api.modrinth.com/v2/project/${project.archives_base_name}/version?&game_versions=${gameVersions}").withInputStream { i -> inputFile.withOutputStream { it << i } }
|
||||||
|
|
||||||
|
def json = new groovy.json.JsonSlurper().parseText(inputFile.text)
|
||||||
|
def version = json[0].version_number
|
||||||
|
|
||||||
|
//increment patch version
|
||||||
|
def indexedVersionList = version.split(/\./).toList().withIndex()
|
||||||
|
indexedVersionList = indexedVersionList.collect { num, idx -> num.toInteger() }
|
||||||
|
indexedVersionList[2] = indexedVersionList[2].value + 1
|
||||||
|
def updatedVersion = indexedVersionList.join(".")
|
||||||
|
|
||||||
|
println "\n\n"
|
||||||
|
println "------------- CURRENT VERSION -------------"
|
||||||
|
println "Last Published Version: " + version
|
||||||
|
println " Game Versions: " + json[0].game_versions
|
||||||
|
println " Status: " + json[0].status
|
||||||
|
println " Featured: " + json[0].featured
|
||||||
|
println " Downloaded: " + json[0].downloads
|
||||||
|
println "\n"
|
||||||
|
println "-------------- NEXT VERSION ---------------"
|
||||||
|
println "Next Version: " + updatedVersion
|
||||||
|
println "\n\n"
|
||||||
|
|
||||||
|
def propertiesFile = new File("gradle.properties")
|
||||||
|
def newContents = propertiesFile.text.replaceFirst("mod_version=\\d+.\\d+.\\d+", "mod_version=${updatedVersion}")
|
||||||
|
propertiesFile.text = newContents
|
||||||
|
|
||||||
|
def fabricFile = new File("src/main/resources/fabric.mod.json")
|
||||||
|
newContents = fabricFile.text.replaceFirst('"version": ".+"', "\"version\": \"${updatedVersion}\"")
|
||||||
|
fabricFile.text = newContents
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue