fix build script

This commit is contained in:
Ryder Belserion 2024-06-15 01:06:32 -04:00
parent 22250d5328
commit c705274c18
No known key found for this signature in database
5 changed files with 62 additions and 81 deletions

View File

@ -1,3 +1,65 @@
plugins {
alias(libs.plugins.minotaur)
alias(libs.plugins.hangar)
`root-plugin`
}
val buildNumber: String? = System.getenv("BUILD_NUMBER")
rootProject.version = if (buildNumber != null) "3.12-$buildNumber" else "3.12"
val isSnapshot = false
val content: String = rootProject.file("CHANGELOG.md").readText(Charsets.UTF_8)
modrinth {
token.set(System.getenv("MODRINTH_TOKEN"))
projectId.set(rootProject.name.lowercase())
versionType.set(if (isSnapshot) "beta" else "release")
versionName.set("${rootProject.name} ${rootProject.version}")
versionNumber.set(rootProject.version as String)
changelog.set(content)
uploadFile.set(rootProject.projectDir.resolve("jars/${rootProject.name}-${rootProject.version}.jar"))
gameVersions.set(listOf(libs.versions.minecraft.get()))
loaders.add("paper")
loaders.add("purpur")
autoAddDependsOn.set(false)
detectLoaders.set(false)
}
hangarPublish {
publications.register("plugin") {
apiKey.set(System.getenv("HANGAR_KEY"))
id.set(rootProject.name.lowercase())
version.set(rootProject.version as String)
channel.set(if (isSnapshot) "Snapshot" else "Release")
changelog.set(content)
platforms {
paper {
jar.set(rootProject.projectDir.resolve("jars/${rootProject.name}-${rootProject.version}.jar"))
platformVersions.set(listOf(libs.versions.minecraft.get()))
dependencies {
hangar("PlaceholderAPI") {
required = false
}
}
}
}
}
}

View File

@ -9,6 +9,4 @@ repositories {
dependencies {
implementation(libs.paperweight.userdev)
implementation(libs.publishing.modrinth)
implementation(libs.publishing.hangar)
}

View File

@ -1,14 +0,0 @@
plugins {
id("root-plugin")
}
val mcVersion = providers.gradleProperty("mcVersion").get()
val fabricVersion = providers.gradleProperty("version").get()
project.version = if (System.getenv("BUILD_NUMBER") != null) "$fabricVersion-${System.getenv("BUILD_NUMBER")}" else fabricVersion
tasks {
modrinth {
loaders.addAll("fabric")
}
}

View File

@ -14,14 +14,4 @@ repositories {
maven("https://repo.fancyplugins.de/releases/")
flatDir { dirs("libs") }
}
val mcVersion = providers.gradleProperty("mcVersion").get()
project.version = if (System.getenv("BUILD_NUMBER") != null) "${rootProject.version}-${System.getenv("BUILD_NUMBER")}" else rootProject.version
tasks {
modrinth {
loaders.addAll("paper", "purpur")
}
}

View File

@ -1,10 +1,4 @@
import io.papermc.hangarpublishplugin.model.Platforms
plugins {
id("io.papermc.hangar-publish-plugin")
id("com.modrinth.minotaur")
`java-library`
`maven-publish`
@ -41,53 +35,4 @@ tasks {
processResources {
filteringCharset = Charsets.UTF_8.name()
}
val directory = File("$rootDir/jars/${project.name.lowercase()}")
val mcVersion = providers.gradleProperty("mcVersion").get()
val isBeta: Boolean = providers.gradleProperty("isBeta").get().toBoolean()
val type = if (isBeta) "Beta" else "Release"
// Publish to hangar.papermc.io.
hangarPublish {
publications.register("plugin") {
version.set("${project.version}")
id.set(rootProject.name)
channel.set(type)
changelog.set(rootProject.file("CHANGELOG.md").readText(Charsets.UTF_8))
apiKey.set(System.getenv("hangar_key"))
platforms {
register(Platforms.PAPER) {
jar.set(file("$directory/${rootProject.name}-${project.version}.jar"))
platformVersions.set(listOf(mcVersion))
}
}
}
}
modrinth {
versionType.set(type.lowercase())
autoAddDependsOn.set(false)
token.set(System.getenv("modrinth_token"))
projectId.set(rootProject.name.lowercase())
changelog.set(rootProject.file("CHANGELOG.md").readText(Charsets.UTF_8))
versionName.set("${rootProject.name} ${project.version}")
versionNumber.set("${project.version}")
uploadFile.set("$directory/${rootProject.name}-${project.version}.jar")
gameVersions.add(mcVersion)
}
}