Skip to content

Commit

Permalink
build: change modrinth publication
Browse files Browse the repository at this point in the history
  • Loading branch information
Syrent committed Jun 2, 2024
1 parent 4f79a11 commit 3386258
Showing 1 changed file with 39 additions and 19 deletions.
58 changes: 39 additions & 19 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import io.papermc.hangarpublishplugin.model.Platforms
import org.sayandev.Module
import org.sayandev.getRelocations
import java.io.ByteArrayOutputStream

Expand Down Expand Up @@ -197,23 +198,42 @@ hangarPublish {
}
}

modrinth {
val modrinthApiKey = System.getenv("MODRINTH_API_TOKEN")
val modrinthChangelog = if (System.getenv("MODRINTH_CHANGELOG").isNullOrEmpty()) changelogContent else System.getenv("MODRINTH_CHANGELOG")

token.set(modrinthApiKey)
projectId.set("${property("modrinthProjectID")}")
versionNumber.set(if (isRelease) versionString else publishVersion)
versionType.set(System.getenv("MODRINTH_BUILD_CHANNEL") ?: "beta")
uploadFile.set(project(":sayanvanish-bukkit").tasks.shadowJar.flatMap { it.archiveFile })
additionalFiles.set(listOf(
project(":sayanvanish-proxy:sayanvanish-proxy-velocity").tasks.shadowJar.flatMap { it.archiveFile },
project(":sayanvanish-proxy:sayanvanish-proxy-bungeecord").tasks.shadowJar.flatMap { it.archiveFile },
))
gameVersions.set("${property("modrinthMinecraftVersions")}".split(","))
loaders.set("${property("modrinthLoaders")}".split(","))

changelog.set(modrinthChangelog)

syncBodyFrom.set(rootProject.file("README.md").readText())
val modrinthModules = listOf(Module.BUKKIT, Module.VELOCITY, Module.BUNGEECORD)
for (module in modrinthModules) {
modrinth {
val modrinthApiKey = System.getenv("MODRINTH_API_TOKEN")
val modrinthChangelog = if (System.getenv("MODRINTH_CHANGELOG").isNullOrEmpty()) changelogContent else System.getenv("MODRINTH_CHANGELOG")

token.set(modrinthApiKey)
projectId.set("${property("modrinthProjectID")}")
versionNumber.set(if (isRelease) versionString else publishVersion)
versionType.set(System.getenv("MODRINTH_BUILD_CHANNEL") ?: "beta")
when (module) {
Module.BUKKIT -> {
uploadFile.set(project(":sayanvanish-bukkit").tasks.shadowJar.flatMap { it.archiveFile })
}
Module.VELOCITY -> {
uploadFile.set(project(":sayanvanish-proxy:sayanvanish-proxy-velocity").tasks.shadowJar.flatMap { it.archiveFile })
}
Module.BUNGEECORD -> {
uploadFile.set(project(":sayanvanish-proxy:sayanvanish-proxy-bungeecord").tasks.shadowJar.flatMap { it.archiveFile })
}
else -> {
throw IllegalArgumentException("Unknown module $module")
}
}
gameVersions.set("${property("modrinthMinecraftVersions")}".split(","))
loaders.set(
when (module) {
Module.BUKKIT -> listOf("paper", "purpur", "spigot", "folia")
Module.VELOCITY -> listOf("velocity")
Module.BUNGEECORD -> listOf("bungeecord", "waterfall")
else -> throw IllegalArgumentException("Unknown module $module")
}
)

changelog.set(modrinthChangelog)

syncBodyFrom.set(rootProject.file("README.md").readText())
}
}

0 comments on commit 3386258

Please sign in to comment.