From 785345d98b736fe01fd23afa52cd2bc076028135 Mon Sep 17 00:00:00 2001 From: Tryfle Date: Sat, 20 Jun 2026 12:11:59 -0400 Subject: [PATCH] chore: add versionrange, add modrinth publish --- CHANGELOG.md | 2 ++ build.gradle.kts | 57 +++++++++++++++++++++--------- gradle.properties | 4 +-- src/main/resources/fabric.mod.json | 7 +++- versions/1.21.1/gradle.properties | 4 ++- versions/1.21.10/gradle.properties | 4 ++- versions/1.21.11/gradle.properties | 4 ++- versions/1.21.4/gradle.properties | 4 ++- versions/1.21.5/gradle.properties | 3 +- versions/1.21.8/gradle.properties | 4 ++- versions/26.1/gradle.properties | 4 ++- 11 files changed, 71 insertions(+), 26 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..c399503 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,2 @@ +## 1.1.1-beta.1 +- Full support for 1.21.1-26.1.2 \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index e0dd50c..4e86977 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -13,6 +13,8 @@ val modname = property("mod.name") val modversion = property("mod.version") val mcversion = stonecutter.current.version val oneconfigversion = property("oneconfig_version") +val versionrange = property("minecraft_version_range") +val loaderversion = property("loader_version") version = "$modversion+$mcversion" base.archivesName = modname.toString() @@ -83,8 +85,8 @@ tasks.processResources { "mod_id" to modid, "mod_name" to modname, "mod_version" to modversion, - "mc_version" to mcversion, - "loader_version" to providers.gradleProperty("loader_version").get() + "minecraft_version_range" to versionrange, + "loader_version" to loaderversion ) inputs.properties(props) @@ -125,34 +127,57 @@ tasks.jar { fun optionalProp(property: String, block: (String) -> T?): T? = findProperty(property)?.toString()?.takeUnless { it.isBlank() }?.let(block) -val modrinthId = findProperty("publish.modrinth")?.toString()?.takeIf { it.isNotBlank() } +val modrinthMinecraftVersionOverride = mapOf( + "26.1" to listOf("26.1", "26.1.1", "26.1.2"), + "26.1.1" to listOf("26.1", "26.1.1", "26.1.2"), + "26.1.2" to listOf("26.1", "26.1.1", "26.1.2") +) + +val modrinthId = listOf("oneconfig.publish.modrinth", "publish.modrinth").firstNotNullOfOrNull { findProperty(it) }?.toString()?.takeIf { it.isNotBlank() } +val modrinthToken = listOf("oneconfig.publish.modrinth.token", "publish.modrinth.token", "modrinth.token").firstNotNullOfOrNull { findProperty(it) }?.toString()?.takeIf { it.isNotBlank() } +val minecraftVersion = modrinthMinecraftVersionOverride[mcversion] ?: listOf(mcversion) +val publishJarTaskName = if ("remapJar" in tasks.names) "remapJar" else "jar" +val changelogs = rootProject.file("CHANGELOG.md").takeIf { it.exists() }?.readText() ?: "No changelog provided." + +val validateChangelog by tasks.registering { + description = "Validates that the changelog is written for the current version." + if (!changelogs.contains(modversion.toString())) { + throw GradleException("Changelog for version $modversion not found.") + } +} + +tasks.publishMods.configure { + dependsOn(validateChangelog) +} +tasks.matching { it.name == "publishModrinth" }.configureEach { + dependsOn(validateChangelog) +} -// make sure modrinth.token is set in your user gradle properties publishMods { - file = if (stonecutter.current.parsed >= "26.1") { - project.tasks.jar.get().archiveFile - } else { - project.tasks.named("remapJar").flatMap { it.archiveFile } - } + file = tasks.named(publishJarTaskName).flatMap { it.archiveFile } displayName = modversion.toString() version = "v$modversion" - changelog = - project.rootProject.file("CHANGELOG.md").takeIf { it.exists() }?.readText() ?: "No changelog provided." - type = ALPHA + changelog = changelogs + type = BETA modLoaders.add("fabric") - dryRun = modrinthId == null + dryRun = modrinthId == null || modrinthToken == null if (modrinthId != null) { modrinth { - projectId = property("publish.modrinth").toString() - accessToken = findProperty("modrinth.token").toString() + projectId = modrinthId + accessToken = modrinthToken.orEmpty() - minecraftVersions.add(mcversion) + minecraftVersions.addAll(minecraftVersion) requires("oneconfig") + requires("fabric-language-kotlin") + findProperty("publish.modrinth.compose-bundle") + ?.toString() + ?.takeIf { it.isNotBlank() } + ?.let { requires(it) } } } } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index ee2f6e9..cb09161 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ mod.name=PolyWeather mod.id=polyweather -mod.version=1.1.0-alpha.2 +mod.version=1.1.1-beta.1 mod.group=org.polyfrost loomx.loom_version=1.16-SNAPSHOT @@ -15,7 +15,7 @@ org.gradle.daemon=true org.gradle.parallel=true org.gradle.configureoncommand=true org.gradle.parallel.threads=4 -org.gradle.jvmargs=-Xmx2G +org.gradle.jvmargs=-Xmx4G # Fix YALMM fabric.loom.dropNonIntermediateRootMethods=true \ No newline at end of file diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 1f882d6..61b2f7c 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -24,5 +24,10 @@ "mixins.${mod_id}.json" ], "license": "GPL 3.0", - "environment": "client" + "environment": "client", + "depends": { + "minecraft": "${minecraft_version_range}", + "fabricloader": ">=${loader_version}", + "fabric-language-kotlin": "*" + } } \ No newline at end of file diff --git a/versions/1.21.1/gradle.properties b/versions/1.21.1/gradle.properties index 7e5b56e..ce17e72 100644 --- a/versions/1.21.1/gradle.properties +++ b/versions/1.21.1/gradle.properties @@ -1,2 +1,4 @@ parchment_version=2024.11.17 -yalmm_version=3 \ No newline at end of file +yalmm_version=3 +minecraft_version=1.21.1 +minecraft_version_range=1.21.1 \ No newline at end of file diff --git a/versions/1.21.10/gradle.properties b/versions/1.21.10/gradle.properties index f4e727f..8ca8654 100644 --- a/versions/1.21.10/gradle.properties +++ b/versions/1.21.10/gradle.properties @@ -1,2 +1,4 @@ parchment_version=2025.10.12 -yalmm_version=3 \ No newline at end of file +yalmm_version=3 +minecraft_version=1.21.10 +minecraft_version_range=>=1.21.9 <=1.21.10 \ No newline at end of file diff --git a/versions/1.21.11/gradle.properties b/versions/1.21.11/gradle.properties index e999cd6..f227b41 100644 --- a/versions/1.21.11/gradle.properties +++ b/versions/1.21.11/gradle.properties @@ -1,2 +1,4 @@ parchment_version=2025.12.20 -yalmm_version=3 \ No newline at end of file +yalmm_version=3 +minecraft_version=1.21.11 +minecraft_version_range=1.21.11 \ No newline at end of file diff --git a/versions/1.21.4/gradle.properties b/versions/1.21.4/gradle.properties index e23569e..d560b5a 100644 --- a/versions/1.21.4/gradle.properties +++ b/versions/1.21.4/gradle.properties @@ -1,2 +1,4 @@ parchment_version=2025.03.23 -yalmm_version=3 \ No newline at end of file +yalmm_version=3 +minecraft_version=1.21.4 +minecraft_version_range=1.21.4 \ No newline at end of file diff --git a/versions/1.21.5/gradle.properties b/versions/1.21.5/gradle.properties index cda4312..4ab5b77 100644 --- a/versions/1.21.5/gradle.properties +++ b/versions/1.21.5/gradle.properties @@ -1,3 +1,4 @@ parchment_version=2025.06.15 yalmm_version=3 -minecraft_version=1.21.5 \ No newline at end of file +minecraft_version=1.21.5 +minecraft_version_range=1.21.5 \ No newline at end of file diff --git a/versions/1.21.8/gradle.properties b/versions/1.21.8/gradle.properties index 4181c79..8209a8b 100644 --- a/versions/1.21.8/gradle.properties +++ b/versions/1.21.8/gradle.properties @@ -1,2 +1,4 @@ parchment_version=2025.09.14 -yalmm_version=3 \ No newline at end of file +yalmm_version=3 +minecraft_version=1.21.8 +minecraft_version_range=>=1.21.7 <=1.21.8 \ No newline at end of file diff --git a/versions/26.1/gradle.properties b/versions/26.1/gradle.properties index bb4b398..e754dab 100644 --- a/versions/26.1/gradle.properties +++ b/versions/26.1/gradle.properties @@ -1,4 +1,6 @@ yalmm_version=3 minecraft_version=26.1 has_official_mappings=false -java_version=25 \ No newline at end of file +java_version=25 + +minecraft_version_range=~26.1 \ No newline at end of file