Merge pull request #1043 from Toshayo/master

Added CurseForge task configuration
This commit is contained in:
HbmMods 2023-05-30 14:44:42 +02:00 committed by GitHub
commit be36bbf25f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 49 additions and 0 deletions

6
.gitignore vendored
View File

@ -20,3 +20,9 @@ build
# other
run
# CurseForge configuration
/curseforge.properties
# Changelog backup
/changelog.bak

View File

@ -1,3 +1,6 @@
import java.nio.file.Files
import java.nio.file.Paths
buildscript {
repositories {
maven { url = 'https://maven.minecraftforge.net/' }
@ -10,6 +13,14 @@ buildscript {
}
apply plugin: 'forge'
apply plugin: 'curseforge'
if(Files.exists(Paths.get("curseforge.properties"))) {
// Load CurseForge configuration
ext.cfprops = parseConfig(file("curseforge.properties"))
}
def version_name = version = mod_version
if(!mod_build_number.isEmpty()) {
version_name = mod_version + "_X" + mod_build_number
@ -114,3 +125,30 @@ task version {
println project.version
}
}
if(Files.exists(Paths.get("curseforge.properties"))) {
curse {
apiKey = cfprops.api_key
projectId = cfprops.project_id
releaseType = "release"
if (Files.exists(Paths.get("changelog"))) {
changelog = String.join("\r\n", Files.readAllLines(Paths.get("changelog")))
// Perform a backup of the changelog and create a new file for next changes
doLast {
Files.move(Paths.get("changelog"), Paths.get("changelog.bak"))
Files.createFile(Paths.get("changelog"))
}
}
}
}
// Properties file parsing helper
static def parseConfig(File config) {
config.withReader {
def prop = new Properties()
prop.load(it)
return (new ConfigSlurper().parse(prop))
}
}

0
changelog Normal file
View File

View File

@ -0,0 +1,5 @@
# CurseForge API token (obtainable from https://legacy.curseforge.com/account/api-tokens)
api_key=
# CurseForge project ID
project_id=