mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +02:00
try hangar release
This commit is contained in:
parent
62205085c7
commit
152e2c8d86
3 changed files with 89 additions and 4 deletions
|
|
@ -2,7 +2,10 @@ import cn.lalaki.pub.BaseCentralPortalPlusExtension
|
|||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
import groovy.util.Node
|
||||
import groovy.util.NodeList
|
||||
import io.papermc.hangarpublishplugin.model.HangarPublication
|
||||
import io.papermc.hangarpublishplugin.model.Platforms
|
||||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
||||
import java.io.ByteArrayOutputStream
|
||||
|
||||
plugins {
|
||||
kotlin("jvm") version "2.1.0"
|
||||
|
|
@ -15,13 +18,16 @@ plugins {
|
|||
id("cn.lalaki.central").version("1.2.8")
|
||||
// Paper
|
||||
id("io.papermc.paperweight.userdev") version "2.0.0-beta.17" apply false
|
||||
id("io.papermc.hangar-publish-plugin") version "0.1.2"
|
||||
}
|
||||
|
||||
group = "xyz.alexcrea"
|
||||
version = "1.15.9"
|
||||
|
||||
val isDevBuild = System.getenv("SMALL_COMMIT_HASH") != null
|
||||
val isPreRelease = System.getenv("IS_PRERELEASE") == "true"
|
||||
val effectiveVersion = "$version" +
|
||||
(if (System.getenv("SMALL_COMMIT_HASH") != null) "-dev-${System.getenv("SMALL_COMMIT_HASH")!!}" else "")
|
||||
(if (isDevBuild) "-dev-${System.getenv("SMALL_COMMIT_HASH")!!}" else "")
|
||||
|
||||
repositories {
|
||||
// EcoEnchants
|
||||
|
|
@ -319,3 +325,71 @@ publishing {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// hangar publish
|
||||
|
||||
fun executeGitCommand(vararg command: String): String {
|
||||
val byteOut = ByteArrayOutputStream()
|
||||
exec {
|
||||
commandLine = listOf("git", *command)
|
||||
standardOutput = byteOut
|
||||
}
|
||||
return byteOut.toString(Charsets.UTF_8.name()).trim()
|
||||
}
|
||||
|
||||
|
||||
fun latestCommitMessage(): String {
|
||||
return executeGitCommand("log", "-1", "--pretty=%B")
|
||||
}
|
||||
|
||||
fun changelog(isOnline: Boolean): String {
|
||||
var changelog = if(isDevBuild) latestCommitMessage()
|
||||
else System.getenv("RELEASE_CHANGELOG")
|
||||
|
||||
if(!isOnline) {
|
||||
changelog = "This is an offline version of the plugin. \\\n" +
|
||||
"This mean that this plugin libraries are shaded into this plugin \\\n" +
|
||||
"You likely want to use the normal version of this plugin\n\n" + changelog
|
||||
}
|
||||
|
||||
return changelog
|
||||
}
|
||||
|
||||
hangarPublish {
|
||||
|
||||
fun HangarPublication.configure(isOnline: Boolean, devChannel: String, releaseChannel: String) {
|
||||
version.set(effectiveVersion)
|
||||
channel.set(if (isDevBuild || isPreRelease) devChannel else releaseChannel)
|
||||
|
||||
changelog.set(changelog(isOnline))
|
||||
id.set("CustomAnvil")
|
||||
apiKey.set(System.getenv("HANGAR_API_TOKEN"))
|
||||
|
||||
platforms {
|
||||
register(Platforms.PAPER) {
|
||||
// Set the JAR file to upload
|
||||
var task = if(isOnline) tasks.shadowJar
|
||||
else tasks.getByName("offlineJar") as TaskProvider<ShadowJar>
|
||||
|
||||
jar.set(task.flatMap { it.archiveFile })
|
||||
|
||||
// Set platform versions from gradle.properties file
|
||||
val versions: List<String> = (property("paperVersion") as String)
|
||||
.split(",")
|
||||
.map { it.trim() }
|
||||
platformVersions.set(versions)
|
||||
|
||||
//TODO dependencies
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
publications.register("plugin") {
|
||||
configure(true, "DevSnapshot", "Release")
|
||||
}
|
||||
|
||||
publications.register("offline") {
|
||||
configure(false, "OfflineSnapshot", "OfflineRelease")
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue