From 4da029729cc79305da6f89208e4526384b363b6f Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 22 May 2022 18:01:35 +0200 Subject: [PATCH] Add rudimentary support for modrinth publishing (#263) * Add rudimentary support for modrinth publishing Signed-off-by: Max * Reformat, disambiguate version number Signed-off-by: Max --- .github/workflows/1.18_push.yml | 3 ++- build.gradle | 11 +++++---- fabric/build.gradle | 29 ++++++++++++++++++++---- forge/build.gradle | 27 ++++++++++++++++++---- gradle.properties | 5 +++- gradle/wrapper/gradle-wrapper.properties | 2 +- 6 files changed, 59 insertions(+), 18 deletions(-) diff --git a/.github/workflows/1.18_push.yml b/.github/workflows/1.18_push.yml index 49de097d..88c3f43f 100644 --- a/.github/workflows/1.18_push.yml +++ b/.github/workflows/1.18_push.yml @@ -71,5 +71,6 @@ jobs: # GIT_PREVIOUS_COMMIT: ${{ github.event.before }} MAVEN_PASS: ${{ secrets.MAVEN_PASS }} CURSE_API_KEY: ${{ secrets.CURSE_API_KEY }} + MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} with: - arguments: publish curseforge --stacktrace --no-daemon + arguments: publish curseforge modrinth --stacktrace --no-daemon diff --git a/build.gradle b/build.gradle index 3e8abac5..048083d4 100644 --- a/build.gradle +++ b/build.gradle @@ -1,3 +1,5 @@ +import java.text.SimpleDateFormat + buildscript { configurations.classpath { resolutionStrategy.cacheChangingModulesFor 0, 'seconds' @@ -6,9 +8,10 @@ buildscript { plugins { id "architectury-plugin" version "3.4-SNAPSHOT" - id "dev.architectury.loom" version "0.11.0-SNAPSHOT" apply false + id "dev.architectury.loom" version "0.12.0-SNAPSHOT" apply false id "org.cadixdev.licenser" version "0.6.1" id "com.matthewprenger.cursegradle" version "1.4.0" apply false + id "com.modrinth.minotaur" version "2.2.0" apply false id "maven-publish" } @@ -37,7 +40,7 @@ allprojects { apply plugin: "java" apply plugin: "architectury-plugin" apply plugin: "org.cadixdev.licenser" - + ext { isSnapshot = System.getenv("PR_NUM") != null } @@ -81,7 +84,7 @@ allprojects { ext { releaseChangelog = { - def dateFormat = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm") + def dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm") dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")) def branch if (System.env.BRANCH_NAME) { @@ -115,5 +118,3 @@ allprojects { task licenseFormatAll subprojects { p -> licenseFormatAll.dependsOn("${p.path}:licenseFormat") } - -task curseforgePublish diff --git a/fabric/build.gradle b/fabric/build.gradle index a0032e09..b0c5bd60 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -1,6 +1,7 @@ plugins { id "com.github.johnrengelman.shadow" version "7.1.2" id "com.matthewprenger.cursegradle" + id "com.modrinth.minotaur" } loom { @@ -99,11 +100,12 @@ publishing { } curseforge { - if (project.hasProperty("CURSE_API_KEY") || System.getenv("CURSE_API_KEY") != null) { - apiKey = project.hasProperty("CURSE_API_KEY") ? project.property("CURSE_API_KEY") : System.getenv("CURSE_API_KEY") + var CURSE_API_KEY = project.findProperty("CURSE_API_KEY") ?: System.getenv("CURSE_API_KEY") + if (CURSE_API_KEY != null) { + apiKey = CURSE_API_KEY project { - id = "419699" - releaseType = "$rootProject.cf_type" + id = rootProject.curseforge_id + releaseType = "$rootProject.artifact_type" changelogType = "html" changelog = releaseChangelog() addGameVersion "1.18.2" @@ -127,4 +129,21 @@ curseforge { } } -rootProject.tasks.getByName("curseforgePublish").dependsOn tasks.getByName("curseforge") +modrinth { + var MODRINTH_TOKEN = project.findProperty("MODRINTH_TOKEN") ?: System.getenv("MODRINTH_TOKEN") + if (MODRINTH_TOKEN != null) { + token = MODRINTH_TOKEN + projectId = rootProject.modrinth_id + versionType = "$rootProject.artifact_type" + versionNumber = "$project.version+$project.name" + versionName = "[Fabric $rootProject.supported_version] v$project.version" + changelog = releaseChangelog() + uploadFile = remapJar + gameVersions = ["1.18.2"] + loaders = ["fabric"] + dependencies { + // TODO: move to slugs if that functionality becomes available in minotaur + required.project("P7dR8mSH") // Fabric API + } + } +} diff --git a/forge/build.gradle b/forge/build.gradle index d91b4213..d2858bec 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -1,6 +1,7 @@ plugins { id "com.github.johnrengelman.shadow" version "7.1.2" id "com.matthewprenger.cursegradle" + id "com.modrinth.minotaur" } loom { @@ -112,11 +113,12 @@ publishing { } curseforge { - if (project.hasProperty("CURSE_API_KEY") || System.getenv("CURSE_API_KEY") != null) { - apiKey = project.hasProperty("CURSE_API_KEY") ? project.property("CURSE_API_KEY") : System.getenv("CURSE_API_KEY") + var CURSE_API_KEY = project.findProperty("CURSE_API_KEY") ?: System.getenv("CURSE_API_KEY") + if (CURSE_API_KEY != null) { + apiKey = CURSE_API_KEY project { - id = "419699" - releaseType = "$rootProject.cf_type" + id = rootProject.curseforge_id + releaseType = "$rootProject.artifact_type" changelogType = "html" changelog = releaseChangelog() addGameVersion "1.18.2" @@ -136,4 +138,19 @@ curseforge { } } -rootProject.tasks.getByName("curseforgePublish").dependsOn tasks.getByName("curseforge") +modrinth { + var MODRINTH_TOKEN = project.findProperty("MODRINTH_TOKEN") ?: System.getenv("MODRINTH_TOKEN") + if (MODRINTH_TOKEN != null) { + token = MODRINTH_TOKEN + projectId = rootProject.modrinth_id + versionType = "$rootProject.artifact_type" + versionNumber = "$project.version+$project.name" + versionName = "[Forge $rootProject.supported_version] v$project.version" + changelog = releaseChangelog() + uploadFile = remapJar + gameVersions = ["1.18.2"] + loaders = ["forge"] + dependencies { + } + } +} diff --git a/gradle.properties b/gradle.properties index 5fee3f9d..e18df335 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ forgeEnabled=true minecraft_version=1.18.2 supported_version=1.18.2 -cf_type=release +artifact_type=release archives_base_name=architectury archives_base_name_snapshot=architectury-snapshot @@ -18,3 +18,6 @@ fabric_api_version=0.50.0+1.18.2 mod_menu_version=3.0.0 forge_version=40.1.14 + +curseforge_id=419699 +modrinth_id=lhGA9TYQ \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 84d1f85f..aa991fce 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists