From 3dcdb83bed3d29f44124ec0c778dc528dc998b1e Mon Sep 17 00:00:00 2001 From: moonleay Date: Wed, 8 May 2024 00:46:36 +0200 Subject: [PATCH] ci: first modrinth publishing test Signed-off-by: moonleay --- .forgejo/workflows/build-dev.yml | 4 ++++ build.gradle.kts | 25 +++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/.forgejo/workflows/build-dev.yml b/.forgejo/workflows/build-dev.yml index 19555b1..0b69732 100644 --- a/.forgejo/workflows/build-dev.yml +++ b/.forgejo/workflows/build-dev.yml @@ -27,3 +27,7 @@ jobs: name: Upload env: PACKAGE_REPO_KEY: ${{ secrets.PACKAGE_REPO_KEY }} + - run: ./gradlew modrinth + name: Publish to Modrinth + env: + MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} diff --git a/build.gradle.kts b/build.gradle.kts index bc4fb9a..4f38d53 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -27,10 +27,12 @@ plugins { `maven-publish` eclipse id("org.jetbrains.gradle.plugin.idea-ext") + id("com.modrinth.minotaur") version "2.+" } -val mavenVersion = System.getenv("CI_COMMIT_TAG") ?: System.getenv("CI_COMMIT_SHORT_SHA")?.let { "$it-dev" } -?: "0.3.0" //"0.0.0-SNAPSHOT" +val mavenVersion = System.getenv("GITHUB_REF_NAME") ?: System.getenv("GITHUB_REF_NAME") + ?.let { "$it-${project.ext["minecraft.version"] as String}" } +?: "0.0.0-${project.ext["minecraft.version"] as String}" val modId: String by project val modName: String by project @@ -204,6 +206,25 @@ publishing { } } +// build.gradle.kts +modrinth { + token.set(System.getenv("MODRINTH_TOKEN")) // Remember to have the MODRINTH_TOKEN environment variable set or else this will fail - just make sure it stays private! + projectId.set(modId) // This can be the project ID or the slug. Either will work! + versionNumber.set(System.getenv(mavenVersion)) // You don't need to set this manually. Will fail if Modrinth has this version already + versionType.set("alpha") // This is the default -- can also be `beta` or `alpha` + uploadFile.set(tasks.remapJar) // With Loom, this MUST be set to `remapJar` instead of `jar`! + gameVersions.addAll(listOf(project.ext["minecraft.version"] as String)) // Must be an array, even with only one version + loaders.add("fabric") // Must also be an array - no need to specify this if you're using Loom or ForgeGradle + dependencies { // A special DSL for creating dependencies + // scope.type + // The scope can be `required`, `optional`, `incompatible`, or `embedded` + // The type can either be `project` or `version` + required.project("fabric-api") // Creates a new required dependency on Fabric API + required.project("fabric-language-kotlin") + } +} + + rootProject.idea.project { this as ExtensionAware configure {