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 4539556 commit 856bbc5
Show file tree
Hide file tree
Showing 6 changed files with 155 additions and 56 deletions.
61 changes: 45 additions & 16 deletions buildSrc/src/main/groovy/multiloader-common.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,12 @@
plugins {
id 'java-library'
id 'maven-publish'
id 'idea'
id 'jacoco'
id 'idea'
id 'jacoco'
id 'com.github.kt3k.coveralls'
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 Expand Up @@ -153,7 +182,7 @@ jar {
'Implementation-Title' : project.name,
'Implementation-Version' : project.jar.archiveVersion,
'Implementation-Vendor' : mod_author,
"Implementation-Timestamp" : new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
"Implementation-Timestamp" : new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
'Built-On-Minecraft' : minecraft_version
])
}
Expand Down Expand Up @@ -265,7 +294,7 @@ tasks.configureEach { task ->

idea {
module {
downloadSources = true
downloadSources = true
downloadJavadoc = true
for (String excludeDirName in ["runs", "out", "logs", "gradle"]) {
File excludeDir = new File(projectDir, excludeDirName)
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/Flopper/issues
display_url=https://www.curseforge.com/minecraft/mc-mods/flopper
description=The Flopper is an early-game block to move around fluids, just like the Hopper does for items.
release_type=release
fingerprint=bd0353b3e8a2810d60dd584e256e364bc3bedd44
neo_form_version=1.21-20240613.152323
parchment_version=2024.06.23
Expand Down
39 changes: 39 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.Constants
import net.darkhax.curseforgegradle.TaskPublishCurseForge

plugins {
id 'multiloader-loader-fabric'
}
Expand All @@ -19,3 +22,39 @@ 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") ? Constants.RELEASE_TYPE_RELEASE : 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.addRequirement("cyclops-core")
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 {
required.project "Z9DM0LJ4" // Cyclops Core
optional.project "ohNO6lps" // forge-config-api-port-fabric
}
}
tasks.modrinth.dependsOn(tasks.remapJar)
35 changes: 35 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.Constants
import net.darkhax.curseforgegradle.TaskPublishCurseForge

plugins {
id 'multiloader-loader-forge'
id 'net.minecraftforge.gradle' version '[6.0.24,6.2)'
Expand All @@ -11,3 +14,35 @@ dependencies {
implementation "org.cyclops.cyclopscore:cyclopscore-${project.minecraft_version}-forge:${project.cyclopscore_version}:deobf"
}
}

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") ? Constants.RELEASE_TYPE_RELEASE : 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")

mainFile.addRequirement("cyclops-core")
}

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() }
}

dependencies {
required.project "Z9DM0LJ4" // Cyclops Core
}
}
tasks.modrinth.dependsOn(tasks.jar)
37 changes: 36 additions & 1 deletion loader-neoforge/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import net.darkhax.curseforgegradle.Constants
import net.darkhax.curseforgegradle.TaskPublishCurseForge

plugins {
id 'multiloader-loader-neoforge'
}
Expand All @@ -9,4 +12,36 @@ dependencies {
} else {
implementation "org.cyclops.cyclopscore:cyclopscore-${project.minecraft_version}-neoforge:${project.cyclopscore_version}:deobf"
}
}
}

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") ? Constants.RELEASE_TYPE_RELEASE : 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")

mainFile.addRequirement("cyclops-core")
}

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() }
}

dependencies {
required.project "Z9DM0LJ4" // Cyclops Core
}
}
tasks.modrinth.dependsOn(tasks.jar)

0 comments on commit 856bbc5

Please sign in to comment.