Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow publishing for multiple Minecraft version ranges #17

Merged
merged 1 commit into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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