Skip to content

Commit a83cf52

Browse files
committed
🔨 chore: add modrinth publishing
1 parent d9eedcb commit a83cf52

2 files changed

Lines changed: 33 additions & 4 deletions

File tree

build.gradle.kts

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ plugins {
55
id("net.fabricmc.fabric-loom-remap") version "1.14-SNAPSHOT"
66
id("org.jetbrains.kotlin.jvm") version "2.3.0"
77
id("dev.deftu.gradle.bloom") version "0.2.0"
8+
id("me.modmuss50.mod-publish-plugin") version "1.1.0"
89
}
910

1011
val modid = property("mod.id")
@@ -13,9 +14,8 @@ val modversion = property("mod.version")
1314
val mcversion = stonecutter.current.version
1415
val oneconfigversion = property("oneconfig_version")
1516

16-
base {
17-
archivesName.set(property("mod.id") as String)
18-
}
17+
version = "$modversion+$mcversion"
18+
base.archivesName = modname.toString()
1919

2020
repositories {
2121
maven("https://maven.parchmentmc.org")
@@ -97,4 +97,31 @@ tasks.jar {
9797
}
9898

9999
fun <T> optionalProp(property: String, block: (String) -> T?): T? =
100-
findProperty(property)?.toString()?.takeUnless { it.isBlank() }?.let(block)
100+
findProperty(property)?.toString()?.takeUnless { it.isBlank() }?.let(block)
101+
102+
val modrinthId = findProperty("publish.modrinth")?.toString()?.takeIf { it.isNotBlank() }
103+
104+
// make sure modrinth.token is set in your user gradle properties
105+
publishMods {
106+
file = project.tasks.remapJar.get().archiveFile
107+
108+
displayName = modversion.toString()
109+
version = "v$modversion"
110+
changelog = project.rootProject.file("CHANGELOG.md").takeIf { it.exists() }?.readText() ?: "No changelog provided."
111+
type = ALPHA
112+
113+
modLoaders.add("fabric")
114+
115+
dryRun = modrinthId == null
116+
117+
if (modrinthId != null) {
118+
modrinth {
119+
projectId = property("publish.modrinth").toString()
120+
accessToken = findProperty("modrinth.token").toString()
121+
122+
minecraftVersions.add(mcversion)
123+
124+
requires("oneconfig")
125+
}
126+
}
127+
}

gradle.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ oneconfig_version=1.0.0-alpha.182
99
parchment_version=[VERSIONED]
1010
yalmm_version=[VERSIONED]
1111

12+
publish.modrinth=r8Cr8YRg
13+
1214
org.gradle.daemon=true
1315
org.gradle.parallel=true
1416
org.gradle.configureoncommand=true

0 commit comments

Comments
 (0)