Task to auto increment build version
This commit is contained in:
parent
edb8a83e77
commit
7fea8ff6d8
2 changed files with 38 additions and 0 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -33,3 +33,4 @@ output/
|
|||
*.log
|
||||
/CHANGES.md
|
||||
/src/main/generated/.cache/
|
||||
/modrinth.json
|
||||
|
|
37
build.gradle
37
build.gradle
|
@ -148,4 +148,41 @@ curseforge {
|
|||
debug = false
|
||||
forgeGradleIntegration = false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
task nextVersion() {
|
||||
doLast {
|
||||
def inputFile = new File('modrinth.json')
|
||||
new URL("https://api.modrinth.com/v2/project/${project.archives_base_name}/version?&game_versions=${project.modrinth_versions}").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…
Reference in a new issue