Skip to content

Commit

Permalink
add publishing setup
Browse files Browse the repository at this point in the history
  • Loading branch information
DeDiamondPro committed Jan 18, 2025
1 parent b801f11 commit 280e1c6
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 73 deletions.
49 changes: 48 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import dev.dediamondpro.buildsource.VersionRange
plugins {
alias(libs.plugins.kotlin)
alias(libs.plugins.shadow)
id("dev.architectury.loom")
alias(libs.plugins.arch.loom)
alias(libs.plugins.publishing)
}

buildscript {
Expand Down Expand Up @@ -179,6 +180,52 @@ base.archivesName.set(
mcVersion.get(mcPlatform).getName().replace("/", "-")
}-${mcPlatform.loaderString})-$mod_version"
)

publishMods {
file.set(tasks.remapJar.get().archiveFile)
displayName.set("[${mcVersion.get(mcPlatform).getName()}-${mcPlatform.loaderString}] $mod_name $mod_version")
version.set(mod_version)
changelog.set(rootProject.file("changelog.md").readText())
type.set(STABLE)

modLoaders.add(mcPlatform.loaderString)
if (mcPlatform.isFabric) modLoaders.add("quilt")
if (mcPlatform.isForge && mcPlatform.version == 1_20_1) modLoaders.add("neoforge")

curseforge {
projectId.set("870076")
accessToken.set(System.getenv("CURSEFORGE_TOKEN"))

minecraftVersionRange {
start = mcVersion.get(mcPlatform).startVersion
end = mcVersion.get(mcPlatform).endVersion
}

if (mcPlatform.isFabric) {
requires("fabric-api", "fabric-language-kotlin")
optional("modmenu")
} else if (mcPlatform.isForgeLike) {
requires("kotlin-for-forge")
}
}
modrinth {
projectId.set("resourcify")
accessToken.set(System.getenv("MODRINTH_TOKEN"))

minecraftVersionRange {
start = mcVersion.get(mcPlatform).startVersion
end = mcVersion.get(mcPlatform).endVersion
}

if (mcPlatform.isFabric) {
requires("fabric-api", "fabric-language-kotlin")
optional("modmenu")
} else if (mcPlatform.isForgeLike) {
requires("kotlin-for-forge")
}
}
}

tasks {
named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJar") {
archiveClassifier.set("dev")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
package dev.dediamondpro.buildsource

class VersionRange(
private val startVersion: String,
private val endVersion: String,
val startVersion: String,
val endVersion: String,
private val name: String = "$startVersion-$endVersion",
private val openEnd: Boolean = false
) {
Expand All @@ -38,21 +38,4 @@ class VersionRange(
fun getForgeRange(): String {
return "[$startVersion," + if (!openEnd) "$endVersion]" else ")"
}

fun asList(): List<String> {
val minorVersion = startVersion.let {
if (it.count { c -> c == '.' } == 1) it else it.substringBeforeLast(".")
}
val start = startVersion.let {
if (it.count { c -> c == '.' } == 1) 0 else it.substringAfterLast(".").toInt()
}
val end = endVersion.let {
if (it.count { c -> c == '.' } == 1) 0 else it.substringAfterLast(".").toInt()
}
val versions = mutableListOf<String>()
for (i in start..end) {
versions.add("$minorVersion${if (i == 0) "" else ".$i"}")
}
return versions
}
}
13 changes: 7 additions & 6 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@
kotlin = "2.0.20"
fabric_language_kotlin = "1.11.0+kotlin.2.0.0" # Use 2.0.0 here since it is the minimum kotlin version we require

# Essential Dependencies
elementa = "DIAMOND-9"
# Build system
arch_loom = "1.7-SNAPSHOT"
shadow = "8.1.1"
publishing = "0.8.3"

# Markdown
minemark = "1.2.3"
commonmark = "0.21.0"
tagsoup = "1.2.1"

# Misc
shadow = "8.1.1"

[libraries]
# Kotlin
kotlin = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" }
Expand All @@ -31,8 +30,10 @@ tagsoup = { module = "org.ccil.cowan.tagsoup:tagsoup", version.ref = "tagsoup" }
# Kotlin
kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }

# Misc
# Build system
arch_loom = { id = "dev.architectury.loom", version.ref = "arch_loom" }
shadow = { id = "com.github.johnrengelman.shadow", version.ref = "shadow" }
publishing = { id = "me.modmuss50.mod-publish-plugin", version.ref = "publishing" }

[bundles]
kotlin = [
Expand Down
46 changes: 0 additions & 46 deletions root.gradle.kts

This file was deleted.

7 changes: 6 additions & 1 deletion stonecutter.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@

plugins {
id("dev.kikugie.stonecutter")
id("dev.architectury.loom") version "1.7-SNAPSHOT" apply false
alias(libs.plugins.arch.loom) apply false
}
stonecutter active "1.21.3-fabric" /* [SC] DO NOT EDIT */

stonecutter registerChiseled tasks.register("chiseledBuild", stonecutter.chiseled) {
group = "project"
ofTask("build")
}

stonecutter registerChiseled tasks.register("chiseledPublishMods", stonecutter.chiseled) {
group = "project"
ofTask("publishMods")
}

0 comments on commit 280e1c6

Please sign in to comment.