1
0
forked from Clones/Controlify

🐘 Migrate to modmuss50 mod publish plugin

This commit is contained in:
isXander
2023-07-21 20:09:30 +01:00
parent 9cb95b0a94
commit 9be29f44cd
2 changed files with 51 additions and 83 deletions

View File

@ -1,14 +1,10 @@
import com.github.breadmoirai.githubreleaseplugin.GithubReleaseTask
plugins {
java
alias(libs.plugins.loom)
alias(libs.plugins.loom.quiltflower)
alias(libs.plugins.minotaur)
alias(libs.plugins.cursegradle)
alias(libs.plugins.github.release)
alias(libs.plugins.mod.publish.plugin)
alias(libs.plugins.machete)
alias(libs.plugins.grgit)
alias(libs.plugins.blossom)
@ -17,7 +13,9 @@ plugins {
group = "dev.isxander"
version = "1.4.4+1.20"
val isAlpha = "alpha" in version.toString()
val isBeta = "beta" in version.toString()
if (isAlpha) println("Alpha version detected.")
if (isBeta) println("Beta version detected.")
repositories {
@ -161,89 +159,63 @@ tasks {
register("releaseMod") {
group = "mod"
dependsOn("modrinth")
dependsOn("modrinthSyncBody")
dependsOn("curseforge")
dependsOn("publishMods")
dependsOn("publish")
dependsOn("githubRelease")
}
named("modrinth") {
dependsOn("optimizeOutputsOfRemapJar")
}
}
val changelogText = file("changelogs/${project.version}.md").takeIf { it.exists() }?.readText() ?: "No changelog provided."
publishMods {
file.set(tasks.remapJar.get().archiveFile)
changelog.set(
file("changelogs/${project.version}.md")
.takeIf { it.exists() }
?.readText()
?: "No changelog provided."
)
type.set(when {
isAlpha -> ALPHA
isBeta -> BETA
else -> STABLE
})
modLoaders.add("fabric")
val modrinthId: String by project
if (modrinthId.isNotEmpty()) {
modrinth {
token.set(findProperty("modrinth.token")?.toString())
projectId.set(modrinthId)
versionNumber.set("${project.version}")
versionType.set(if (isBeta) "beta" else "release")
uploadFile.set(tasks["remapJar"])
gameVersions.set(listOf("1.20", "1.20.1"))
loaders.set(listOf("fabric", "quilt"))
changelog.set(changelogText)
syncBodyFrom.set(file(".github/README.md").readText())
// modrinth and curseforge use different formats for snapshots. this can be expressed globally
val stableMCVersions = listOf("1.20", "1.20.1")
dependencies {
required.project("yacl")
required.project("fabric-api")
optional.project("modmenu")
val modrinthId: String by project
if (modrinthId.isNotBlank() && hasProperty("modrinth.token")) {
modrinth {
projectId.set(modrinthId)
accessToken.set(findProperty("modrinth.token")?.toString())
minecraftVersions.addAll(stableMCVersions)
requires { projectId.set("fabric-api") }
requires { projectId.set("yacl") }
optional { projectId.set("modmenu") }
}
}
}
val curseforgeId: String by project
if (hasProperty("curseforge.token") && curseforgeId.isNotEmpty()) {
curseforge {
apiKey = findProperty("curseforge.token")
project(closureOf<me.hypherionmc.cursegradle.CurseProject> {
mainArtifact(tasks["remapJar"], closureOf<me.hypherionmc.cursegradle.CurseArtifact> {
displayName = "${project.version}"
})
val curseforgeId: String by project
if (curseforgeId.isNotBlank() && hasProperty("curseforge.token")) {
curseforge {
projectId.set(curseforgeId)
accessToken.set(findProperty("curseforge.token")?.toString())
minecraftVersions.addAll(stableMCVersions)
id = curseforgeId
releaseType = if (isBeta) "beta" else "release"
addGameVersion("1.20")
addGameVersion("1.20.1")
addGameVersion("Fabric")
addGameVersion("Java 17")
changelog = changelogText
changelogType = "markdown"
relations(closureOf<me.hypherionmc.cursegradle.CurseRelation> {
requiredDependency("fabric-api")
requiredDependency("yacl")
optionalDependency("modmenu")
})
})
options(closureOf<me.hypherionmc.cursegradle.Options> {
forgeGradleIntegration = false
fabricIntegration = false
})
requires { slug.set("fabric-api") }
requires { slug.set("yacl") }
optional { slug.set("modmenu") }
}
}
}
githubRelease {
token(findProperty("github.token")?.toString())
val githubProject: String by project
val split = githubProject.split("/")
owner(split[0])
repo(split[1])
tagName("${project.version}")
targetCommitish(grgit.branch.current().name)
body(changelogText)
releaseAssets(tasks["remapJar"].outputs.files)
}
tasks.getByName<GithubReleaseTask>("githubRelease") {
dependsOn("optimizeOutputsOfRemapJar")
if (githubProject.isNotBlank() && hasProperty("github.token")) {
github {
repository.set(githubProject)
accessToken.set(findProperty("github.token")?.toString())
commitish.set(grgit.branch.current().name)
}
}
}
publishing {

View File

@ -1,17 +1,15 @@
[versions]
loom = "1.2.+"
loom_quiltflower = "1.8.+"
minotaur = "2.7.+"
cursegradle = "2.+"
github_release = "2.+"
mod_publish_plugin = "0.1.+"
machete = "2.+"
grgit = "5.0.+"
blossom = "1.3.+"
minecraft = "1.20.1"
quilt_mappings = "13"
quilt_mappings = "20"
fabric_loader = "0.14.21"
fabric_api = "0.85.0+1.20.1"
fabric_api = "0.86.0+1.20.1"
mixin_extras = "0.2.0-beta.8"
yet_another_config_lib = "3.0.3+1.20"
mod_menu = "7.0.0"
@ -43,9 +41,7 @@ test_fabric_loader = { module = "net.fabricmc:fabric-loader-junit", version.ref
loom = { id = "fabric-loom", version.ref = "loom" }
loom_quiltflower = { id = "io.github.juuxel.loom-quiltflower", version.ref = "loom_quiltflower" }
minotaur = { id = "com.modrinth.minotaur", version.ref = "minotaur" }
cursegradle = { id = "me.hypherionmc.cursegradle", version.ref = "cursegradle" }
github_release = { id = "com.github.breadmoirai.github-release", version.ref = "github_release" }
mod_publish_plugin = { id = "me.modmuss50.mod-publish-plugin", version.ref = "mod_publish_plugin" }
machete = { id = "io.github.p03w.machete", version.ref = "machete" }
grgit = { id = "org.ajoberstar.grgit", version.ref = "grgit" }
blossom = { id = "net.kyori.blossom", version.ref = "blossom" }