Skip to content

Commit

Permalink
Restore CF and MR publishing tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensworks committed Aug 18, 2024
1 parent fe96ce0 commit 9df7fd7
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 51 deletions.
53 changes: 41 additions & 12 deletions buildSrc/src/main/groovy/multiloader-common.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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}"
Expand Down
38 changes: 0 additions & 38 deletions buildSrc/src/main/groovy/multiloader-loader.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
1 change: 0 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
37 changes: 37 additions & 0 deletions loader-fabric/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import net.darkhax.curseforgegradle.TaskPublishCurseForge
import net.darkhax.curseforgegradle.Constants as CFG_Constants

plugins {
id 'multiloader-loader-fabric'
}
Expand All @@ -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)
29 changes: 29 additions & 0 deletions loader-forge/build.gradle
Original file line number Diff line number Diff line change
@@ -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)'
Expand Down Expand Up @@ -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)
29 changes: 29 additions & 0 deletions loader-neoforge/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import net.darkhax.curseforgegradle.TaskPublishCurseForge
import net.darkhax.curseforgegradle.Constants as CFG_Constants

plugins {
id 'multiloader-loader-neoforge'
}
Expand Down Expand Up @@ -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)

0 comments on commit 9df7fd7

Please sign in to comment.