From 9df7fd754e9692da3402f9abe5b5741405826f11 Mon Sep 17 00:00:00 2001 From: Ruben Taelman Date: Sun, 18 Aug 2024 06:35:13 +0200 Subject: [PATCH] Restore CF and MR publishing tasks --- .../src/main/groovy/multiloader-common.gradle | 53 ++++++++++++++----- .../src/main/groovy/multiloader-loader.gradle | 38 ------------- gradle.properties | 1 - loader-fabric/build.gradle | 37 +++++++++++++ loader-forge/build.gradle | 29 ++++++++++ loader-neoforge/build.gradle | 29 ++++++++++ 6 files changed, 136 insertions(+), 51 deletions(-) diff --git a/buildSrc/src/main/groovy/multiloader-common.gradle b/buildSrc/src/main/groovy/multiloader-common.gradle index 66ed3c5836..d1a4f4479e 100644 --- a/buildSrc/src/main/groovy/multiloader-common.gradle +++ b/buildSrc/src/main/groovy/multiloader-common.gradle @@ -9,18 +9,6 @@ plugins { id 'com.diffplug.spotless' } -// Load secrets -def getSecrets() { - Properties props = new Properties() - if (file('../secrets.properties').exists()) { - props.load(new FileInputStream(file('../secrets.properties'))) - } - return props -} -ext { - secrets = getSecrets(); -} - // Determine build number String build_number = "DEV" // this will be referenced as simply build_number from now on. if (System.getenv().BUILD_NUMBER) @@ -33,6 +21,47 @@ if (System.getenv().RELEASE || System.getenv().TRAVIS_TAG) build_number = "RELEASE" logger.lifecycle "BUILDING VERSION: " + build_number +// Load secrets +def getSecrets() { + Properties props = new Properties() + if (file('../secrets.properties').exists()) { + props.load(new FileInputStream(file('../secrets.properties'))) + } + return props +} +def getCurseforgeKey() { + if(secrets.curseforge_key) { + return secrets.curseforge_key + } else if(System.getenv().GITHUB_ACTIONS && System.getenv().CURSEFORGE_KEY_SECRET) { + return System.getenv().CURSEFORGE_KEY_SECRET + } else { + return "DUMMY" + } +} +def getModrinthKey() { + if(secrets.modrinth_key) { + return secrets.modrinth_key + } else if(System.getenv().GITHUB_ACTIONS && System.getenv().MODRINTH_KEY_SECRET) { + return System.getenv().MODRINTH_KEY_SECRET + } else { + return "DUMMY" + } +} +def getChangelog() { + def path = "../resources/changelog/${project.minecraft_version}-${project.version}.txt"; + if (new File(path).exists()) { + return path; + } + return ""; +} +ext { + secrets = getSecrets(); + secrets.curseforgeKey = getCurseforgeKey(); + secrets.modrinthKey = getModrinthKey(); + secrets.changelog = getChangelog(); + secrets.build_number = build_number; +} + // Include build number in version if (build_number.equals("RELEASE")) version = "${project.mod_version}" diff --git a/buildSrc/src/main/groovy/multiloader-loader.gradle b/buildSrc/src/main/groovy/multiloader-loader.gradle index bdb0ee3d3a..3f3123188b 100644 --- a/buildSrc/src/main/groovy/multiloader-loader.gradle +++ b/buildSrc/src/main/groovy/multiloader-loader.gradle @@ -51,41 +51,3 @@ tasks.named('sourcesJar', Jar) { dependsOn(configurations.commonResources) from(configurations.commonResources) } - -// TODO: restore -//tasks.register('publishCurseForge').configure { -// dependsOn(tasks.jar) -// -// if(secrets.hasProperty("curseforge_key") && secrets.hasProperty("changelog")) { -// apiToken = secrets.curseforge_key -// } else if(System.getenv().GITHUB_ACTIONS && System.getenv().CURSEFORGE_KEY_SECRET) { -// apiToken = System.getenv().CURSEFORGE_KEY_SECRET -// } else { -// apiToken = "DUMMY" -// } -// -// def mainFile = upload(project.curseforge_project_id, jar) -// mainFile.releaseType = 'release' -// mainFile.changelogType = "text" -// mainFile.changelog = file("resources/changelog/${project.minecraft_version}-${project.version}.txt") -// mainFile.addGameVersion(project.minecraft_version) -//} - -modrinth { - if(secrets.modrinth_key) { - token = secrets.modrinth_key - } else if(System.getenv().GITHUB_ACTIONS && System.getenv().MODRINTH_KEY_SECRET) { - token = System.getenv().MODRINTH_KEY_SECRET - } else { - token = "DUMMY" - } - projectId = "${modrinth_project_id}" - versionNumber = project.minecraft_version + '-' + project.mod_version - versionType = project.release_type - uploadFile = jar - gameVersions = [ project.minecraft_version ] - changelog = "" - if (new File("resources/changelog/${project.version}.txt").exists()) { - changelog = new File("resources/changelog/${project.version}.txt").text - } -} diff --git a/gradle.properties b/gradle.properties index d21b16650a..26760c7b2d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,7 +12,6 @@ license=MIT issue_tracker_url=https://github.com/CyclopsMC/CyclopsCore/issues display_url=https://www.curseforge.com/minecraft/mc-mods/cyclops-core description=Coremod for Integrated Dynamics, EvilCraft and others. -release_type=release fingerprint=bd0353b3e8a2810d60dd584e256e364bc3bedd44 neo_form_version=1.21-20240613.152323 parchment_version=2024.06.23 diff --git a/loader-fabric/build.gradle b/loader-fabric/build.gradle index 2df2fcd21d..ca53e55166 100644 --- a/loader-fabric/build.gradle +++ b/loader-fabric/build.gradle @@ -1,3 +1,6 @@ +import net.darkhax.curseforgegradle.TaskPublishCurseForge +import net.darkhax.curseforgegradle.Constants as CFG_Constants + plugins { id 'multiloader-loader-fabric' } @@ -12,3 +15,37 @@ repositories { dependencies { modApi "fuzs.forgeconfigapiport:forgeconfigapiport-fabric:${forgeconfigapiport_fabric_version}" } + +task publishCurseForge(type: TaskPublishCurseForge) { + dependsOn(tasks.remapJar) + apiToken = secrets.curseforgeKey; + def mainFile = upload(project.curseforge_project_id, remapJar) + mainFile.releaseType = secrets.build_number.equals("RELEASE") ? CFG_Constants.RELEASE_TYPE_RELEASE : CFG_Constants.RELEASE_TYPE_BETA + mainFile.changelogType = "text" + mainFile.changelog = secrets.changelog ? file(secrets.changelog) : "" + mainFile.addJavaVersion("Java ${project.java_version}") + mainFile.addGameVersion(project.minecraft_version) + mainFile.addModLoader("Fabric") + mainFile.addModLoader("Quilt") + + mainFile.addOptional("forge-config-api-port-fabric") +} + +modrinth { + token = secrets.modrinthKey; + projectId = "${modrinth_project_id}" + versionNumber = project.minecraft_version + '-' + project.mod_version + versionName = "${project.version} for Fabric ${project.minecraft_version}" + versionType = secrets.build_number.equals("RELEASE") ? "release" : "beta" + uploadFile = remapJar + gameVersions = [ project.minecraft_version ] + loaders = ["fabric", "quilt"] + if (secrets.changelog) { + changelog = provider { file(secrets.changelog).readText() } + } + + dependencies { + optional.project "ohNO6lps" // forge-config-api-port-fabric + } +} +tasks.modrinth.dependsOn(tasks.remapJar) diff --git a/loader-forge/build.gradle b/loader-forge/build.gradle index b5b6a023bd..ecad3002f6 100644 --- a/loader-forge/build.gradle +++ b/loader-forge/build.gradle @@ -1,3 +1,6 @@ +import net.darkhax.curseforgegradle.TaskPublishCurseForge +import net.darkhax.curseforgegradle.Constants as CFG_Constants + plugins { id 'multiloader-loader-forge' id 'net.minecraftforge.gradle' version '[6.0.24,6.2)' @@ -91,3 +94,29 @@ javadoc { source = [sourceSets.main.allJava, sourceSets.api.allJava] exclude 'org/cyclops/cyclopscore/modcompat/curios/*' } + +task publishCurseForge(type: TaskPublishCurseForge) { + dependsOn(tasks.jar) + apiToken = secrets.curseforgeKey; + def mainFile = upload(project.curseforge_project_id, jar) + mainFile.releaseType = secrets.build_number.equals("RELEASE") ? CFG_Constants.RELEASE_TYPE_RELEASE : CFG_Constants.RELEASE_TYPE_BETA + mainFile.changelogType = "text" + mainFile.changelog = secrets.changelog ? file(secrets.changelog) : "" + mainFile.addJavaVersion("Java ${project.java_version}") + mainFile.addGameVersion(project.minecraft_version) + mainFile.addModLoader("Forge") +} + +modrinth { + token = secrets.modrinthKey; + projectId = "${modrinth_project_id}" + versionNumber = project.minecraft_version + '-' + project.mod_version + versionName = "${project.version} for Forge ${project.minecraft_version}" + versionType = secrets.build_number.equals("RELEASE") ? "release" : "beta" + uploadFile = jar + gameVersions = [ project.minecraft_version ] + if (secrets.changelog) { + changelog = provider { file(secrets.changelog).readText() } + } +} +tasks.modrinth.dependsOn(tasks.jar) diff --git a/loader-neoforge/build.gradle b/loader-neoforge/build.gradle index 675eae2005..69363a7ab0 100644 --- a/loader-neoforge/build.gradle +++ b/loader-neoforge/build.gradle @@ -1,3 +1,6 @@ +import net.darkhax.curseforgegradle.TaskPublishCurseForge +import net.darkhax.curseforgegradle.Constants as CFG_Constants + plugins { id 'multiloader-loader-neoforge' } @@ -58,3 +61,29 @@ javadoc { source = [sourceSets.main.allJava, sourceSets.api.allJava] exclude 'org/cyclops/cyclopscore/modcompat/curios/*' } + +task publishCurseForge(type: TaskPublishCurseForge) { + dependsOn(tasks.jar) + apiToken = secrets.curseforgeKey; + def mainFile = upload(project.curseforge_project_id, jar) + mainFile.releaseType = secrets.build_number.equals("RELEASE") ? CFG_Constants.RELEASE_TYPE_RELEASE : CFG_Constants.RELEASE_TYPE_BETA + mainFile.changelogType = "text" + mainFile.changelog = secrets.changelog ? file(secrets.changelog) : "" + mainFile.addJavaVersion("Java ${project.java_version}") + mainFile.addGameVersion(project.minecraft_version) + mainFile.addModLoader("NeoForge") +} + +modrinth { + token = secrets.modrinthKey; + projectId = "${modrinth_project_id}" + versionNumber = project.minecraft_version + '-' + project.mod_version + versionName = "${project.version} for NeoForge ${project.minecraft_version}" + versionType = secrets.build_number.equals("RELEASE") ? "release" : "beta" + uploadFile = jar + gameVersions = [ project.minecraft_version ] + if (secrets.changelog) { + changelog = provider { file(secrets.changelog).readText() } + } +} +tasks.modrinth.dependsOn(tasks.jar)