Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-19 14:30:16 +01:00
Setup Hangar and modrinth autopublishing
Dieser Commit ist enthalten in:
Ursprung
c358245c0b
Commit
28787340d1
@ -38,6 +38,24 @@ fun Project.latestCommitHash(): String {
|
||||
return byteOut.toString(Charsets.UTF_8.name()).trim()
|
||||
}
|
||||
|
||||
fun Project.lastCommitMessage(): String {
|
||||
val byteOut = ByteArrayOutputStream()
|
||||
exec {
|
||||
commandLine = listOf("git", "log", "-1", "--pretty=%B")
|
||||
standardOutput = byteOut
|
||||
}
|
||||
return byteOut.toString(Charsets.UTF_8.name()).trim()
|
||||
}
|
||||
|
||||
fun Project.branchName(): String {
|
||||
val byteOut = ByteArrayOutputStream()
|
||||
exec {
|
||||
commandLine = listOf("git", "branch")
|
||||
standardOutput = byteOut
|
||||
}
|
||||
return byteOut.toString(Charsets.UTF_8.name()).trim()
|
||||
}
|
||||
|
||||
fun JavaPluginExtension.javaTarget(version: Int) {
|
||||
toolchain.languageVersion.set(JavaLanguageVersion.of(version))
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
# Project properties - we put these here so they can be modified without causing a recompile of the build scripts
|
||||
projectVersion=4.8.0-23w32a-SNAPSHOT
|
||||
mcVersions=1.20.1, 1.19.4, 1.18.2, 1.17.1, 1.16.5, 1.15.2, 1.14.4, 1.8.9
|
||||
mcVersionRange=1.8-1.20.1
|
||||
|
||||
# Gradle properties
|
||||
org.gradle.daemon=true
|
||||
|
@ -1,7 +1,10 @@
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
import io.papermc.hangarpublishplugin.model.Platforms
|
||||
|
||||
plugins {
|
||||
id("com.github.johnrengelman.shadow")
|
||||
id("io.papermc.hangar-publish-plugin") version "0.0.5"
|
||||
id("com.modrinth.minotaur") version "2.+"
|
||||
}
|
||||
|
||||
val platforms = setOf(
|
||||
@ -39,3 +42,45 @@ tasks {
|
||||
}
|
||||
|
||||
publishShadowJar()
|
||||
|
||||
val env: MutableMap<String, String> = System.getenv()
|
||||
val branch = rootProject.branchName()
|
||||
val ver = (project.version as String) + "+" + env["GITHUB_RUN_NUMBER"]
|
||||
val changelogContent = rootProject.lastCommitMessage()
|
||||
modrinth {
|
||||
val mcVersions: List<String> = (property("mcVersions") as String)
|
||||
.split(",")
|
||||
.map { it.trim() }
|
||||
token.set(env["MODRINTH_TOKEN"])
|
||||
projectId.set("viaversion")
|
||||
versionType.set(if (branch == "master") "beta" else "alpha")
|
||||
versionNumber.set(ver)
|
||||
versionName.set("[$branch] $ver")
|
||||
changelog.set(changelogContent)
|
||||
uploadFile.set(tasks.shadowJar.flatMap { it.archiveFile })
|
||||
gameVersions.set(mcVersions)
|
||||
loaders.add("fabric")
|
||||
autoAddDependsOn.set(false)
|
||||
detectLoaders.set(false)
|
||||
dependencies {
|
||||
optional.project("viafabric")
|
||||
optional.project("viafabricplus")
|
||||
}
|
||||
}
|
||||
|
||||
hangarPublish {
|
||||
publications.register("plugin") {
|
||||
apiEndpoint.set("https://hangar.papermc.dev/api/v1")
|
||||
version.set(ver)
|
||||
namespace("ViaVersion", "ViaVersion")
|
||||
channel.set(if (branch == "master") "Snapshot" else "Alpha")
|
||||
changelog.set(changelogContent)
|
||||
apiKey.set(env["HANGAR_TOKEN"])
|
||||
platforms {
|
||||
register(Platforms.PAPER) {
|
||||
jar.set(tasks.shadowJar.flatMap { it.archiveFile })
|
||||
platformVersions.set(listOf(property("mcVersionRange") as String))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren