From a86425d6321e95be09fb59f9707e961e7db0897a Mon Sep 17 00:00:00 2001 From: yueh Date: Mon, 14 Sep 2020 20:50:23 +0200 Subject: [PATCH] Added curseforge upload --- .github/workflows/release.yml | 13 +++++++++---- build.gradle | 1 + fabric/build.gradle | 34 ++++++++++++++++++++++++++++++++++ forge/build.gradle | 28 +++++++++++++++++++++++++++- gradle.properties | 5 +++++ 5 files changed, 76 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ca1375e..382521c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -31,13 +31,13 @@ jobs: - name: Prepare artifact metadata id: prepare_artifact_metadata run: | - echo ::set-output name=API_ARTIFACT_PATH::./api/build/libs/metrics-api-${RELEASE}.jar + echo ::set-output name=API_ARTIFACT_PATH::./api/build/libs/api-${RELEASE}.jar echo ::set-output name=API_ARTIFACT_NAME::metrics-api-${RELEASE}.jar - echo ::set-output name=CORE_ARTIFACT_PATH::./core/build/libs/metrics-core-${RELEASE}.jar + echo ::set-output name=CORE_ARTIFACT_PATH::./core/build/libs/core-${RELEASE}.jar echo ::set-output name=CORE_ARTIFACT_NAME::metrics-core-${RELEASE}.jar - echo ::set-output name=FABRIC_ARTIFACT_PATH::./fabric/build/libs/metrics-fabric-${RELEASE}.jar + echo ::set-output name=FABRIC_ARTIFACT_PATH::./fabric/build/libs/fabric-${RELEASE}.jar echo ::set-output name=FABRIC_ARTIFACT_NAME::metrics-fabric-${RELEASE}.jar - echo ::set-output name=FORGE_ARTIFACT_PATH::./forge/build/libs/metrics-forge-${RELEASE}.jar + echo ::set-output name=FORGE_ARTIFACT_PATH::./forge/build/libs/forge-${RELEASE}.jar echo ::set-output name=FORGE_ARTIFACT_NAME::metrics-forge-${RELEASE}.jar - name: Upload API Release Artifact uses: actions/upload-release-asset@v1.0.1 @@ -75,3 +75,8 @@ jobs: asset_path: ${{ steps.prepare_artifact_metadata.outputs.FORGE_ARTIFACT_PATH }} asset_name: ${{ steps.prepare_artifact_metadata.outputs.FORGE_ARTIFACT_NAME }} asset_content_type: application/zip + - name: Upload to curseforge + env: + CHANGELOG: ${{ github.event.release.body }} + CURSEFORGE: ${{ secrets.CURSEFORGE }} + run: ./gradlew curseforge --no-daemon --max-workers 1 \ No newline at end of file diff --git a/build.gradle b/build.gradle index 8d2033a..5c5ed8f 100644 --- a/build.gradle +++ b/build.gradle @@ -4,6 +4,7 @@ plugins { id 'fabric-loom' version '0.5.25' apply false id 'com.github.johnrengelman.shadow' version '5.2.0' apply false id "com.diffplug.gradle.spotless" version "4.3.0" + id "com.matthewprenger.cursegradle" version "1.4.0" apply false } repositories { diff --git a/fabric/build.gradle b/fabric/build.gradle index daae2a6..2c66ce1 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -1,5 +1,6 @@ apply plugin: 'fabric-loom' apply plugin: "com.github.johnrengelman.shadow" +apply plugin: 'com.matthewprenger.cursegradle' dependencies { minecraft "com.mojang:minecraft:${project.fabric_minecraft_version}" @@ -25,3 +26,36 @@ remapJar { getInput().set(shadowJar.getArchivePath()); } remapJar.dependsOn shadowJar + +def isAlpha = project.version.contains("alpha") +def isBeta = project.version.contains("beta") + +def cfReleaseType = "release" +if (isAlpha) { + cfReleaseType = "alpha" +} else if (isBeta) { + cfReleaseType = "beta" +} + +if (System.getenv("CURSEFORGE") && !version.endsWith("-SNAPSHOT")) { + curseforge { + apiKey = System.getenv("CURSEFORGE") + project { + id = project.curseforge_project + changelogType = "markdown" + changelog = System.getenv("CHANGELOG") ?: "Please visit our [releases](https://github.com/AppliedEnergistics/MEtrics/releases) for a changelog" + releaseType = cfReleaseType + addGameVersion project.minecraft_version + addGameVersion "Fabric" + mainArtifact(remapJar.archiveFile) { + displayName = "MEtrics ${project.version} [FABRIC]" + } + } + options { + forgeGradleIntegration = false + } + afterEvaluate { + tasks.getByName("curseforge${project.curseforge_project}").dependsOn remapJar + } + } +} \ No newline at end of file diff --git a/forge/build.gradle b/forge/build.gradle index fbc3ad5..248a914 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -14,6 +14,7 @@ buildscript { apply plugin: "com.github.johnrengelman.shadow" apply plugin: 'net.minecraftforge.gradle' apply plugin: 'org.spongepowered.mixin' +apply plugin: 'com.matthewprenger.cursegradle' sourceSets { main { @@ -120,4 +121,29 @@ jar { // This is the preferred method to reobfuscate your jar file jar.finalizedBy('reobfJar') // However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing -//publish.dependsOn('reobfJar') \ No newline at end of file +//publish.dependsOn('reobfJar') + +def isAlpha = project.version.contains("alpha") +def isBeta = project.version.contains("beta") + +def cfReleaseType = "release" +if (isAlpha) { + cfReleaseType = "alpha" +} else if (isBeta) { + cfReleaseType = "beta" +} + +if (System.getenv("CURSEFORGE")) { + curseforge { + apiKey = System.getenv("CURSEFORGE") + project { + id = project.curseforge_project + changelogType = "markdown" + changelog = System.getenv("CHANGELOG") ?: "Please visit our [releases](https://github.com/AppliedEnergistics/MEtrics/releases) for a changelog" + releaseType = cfReleaseType + mainArtifact(jar) { + displayName = "MEtrics ${project.version} [FORGE]" + } + } + } +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 58b15ae..288d6a1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -30,6 +30,11 @@ forge_version=33.0.42 ######################################################### micrometer_version=1.5.4 +######################################################### +# CurseForge # +######################################################### +curseforge_project=407648 + ######################################################### # Gradle Settings # #########################################################