Skip to content

Commit

Permalink
Merge pull request #17 from LostLuma/feature/multi-version-publishing
Browse files Browse the repository at this point in the history
Allow publishing for multiple Minecraft version ranges
  • Loading branch information
Pixaurora authored Dec 31, 2024
2 parents 06cba65 + 06903b4 commit cbd3e08
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
29 changes: 26 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ tasks.withType<Jar> {
}

val modVersion = project.property("mod_version").toString()
val publishVersions = project.property("publish_versions").toString()
val updateTitle = project.property("update_title").toString().uppercaseFirstChar()

fun getVersionType(): ReleaseType {
Expand All @@ -55,6 +56,16 @@ fun getVersionType(): ReleaseType {
}
}

fun isSnapshotVersion(version: String): Boolean {
return if (version.startsWith("a") || version.startsWith("b")) {
true // Alpha and Beta versions
} else if (version.contains("-") || version.contains("w")) {
true // Pre-releases, Release Candidates, Snapshots, etc. ...
} else {
false
}
}

publishMods {
version = modVersion
displayName = "Kit Tunes $updateTitle $modVersion"
Expand All @@ -77,9 +88,21 @@ publishMods {
accessToken = providers.environmentVariable("MODRINTH_SECRET")
projectId = "AVOKl7hB"

minecraftVersionRange {
start = project.property("publish_version_min").toString()
end = project.property("publish_version_max").toString()
publishVersions.split(",").forEach {
val parts = it.split("-")

if (parts.size != 2) {
throw RuntimeException("Invalid version range ${it}.")
}

val a = parts[0]
val b = parts[1]

minecraftVersionRange {
start = a
end = b
includeSnapshots = isSnapshotVersion(a) || isSnapshotVersion(b)
}
}

optional("fabric-api", "qsl", "modmenu")
Expand Down
3 changes: 1 addition & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@ mod_id = kit_tunes
minecraft_version = 1.20.4

# Mod Publish Properties
publish_version_min = 1.17
publish_version_max = 1.21.4
publish_versions = b1.7.3-b1.7.3,1.16-1.21.4
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ annotations = "13.0"
gson = "2.8.0"
slf4j = "2.0.13"

mod_publish = "0.7.4"
mod_publish = "0.8.4"

[libraries]
minecraft = { module = "com.mojang:minecraft", version.ref = "minecraft" }
Expand Down

0 comments on commit cbd3e08

Please sign in to comment.