Skip to content

Commit

Permalink
Merge pull request #227
Browse files Browse the repository at this point in the history
Add hangar publish
  • Loading branch information
Syrent committed Aug 30, 2023
2 parents 45e3ef0 + 48cf155 commit 3187438
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 2 deletions.
50 changes: 49 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
//import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation
import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation
import io.papermc.hangarpublishplugin.model.Platforms
import org.jetbrains.gradle.ext.settings
import org.jetbrains.gradle.ext.taskTriggers
import java.net.URL
import java.util.*
import java.util.concurrent.Executors
import java.io.ByteArrayOutputStream

plugins {
kotlin("jvm") version "1.9.0"
Expand All @@ -14,6 +15,7 @@ plugins {
id("org.jetbrains.gradle.plugin.idea-ext") version "1.1.7"
id("org.screamingsandals.nms-mapper") version "1.4.5"
id("xyz.jpenilla.run-paper") version "2.1.0"
id("io.papermc.hangar-publish-plugin") version "0.1.0"
}

val slug = "velocityvanish"
Expand Down Expand Up @@ -197,6 +199,52 @@ java {
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
}

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")
}

val versionString: String = version as String
val isRelease: Boolean = !versionString.contains('-')

val suffixedVersion: String = if (isRelease) {
versionString
} else {
versionString + "+" + System.getenv("GITHUB_RUN_NUMBER")
}

val changelogContent: String = latestCommitMessage()

hangarPublish {
publications.register("plugin") {
version.set(suffixedVersion)
channel.set(System.getenv("HANGAR_BUILD_CHANNEL") ?: "Snapshot")
changelog.set(changelogContent)
id.set(slug)
apiKey.set(System.getenv("HANGAR_API_TOKEN"))

platforms {
register(Platforms.PAPER) {
jar.set(tasks.shadowJar.flatMap { it.archiveFile })
platformVersions.set((property("paperVersion") as String).split(",").map { it.trim() })
}

register(Platforms.VELOCITY) {
jar.set(tasks.shadowJar.flatMap { it.archiveFile })
platformVersions.set((property("velocityVersion") as String).split(",").map { it.trim() })
}
}
}
}

val templateSource = file("src/main/templates")
val templateDest = layout.buildDirectory.dir("generated/sources/templates")
val generateTemplates = tasks.register<Copy>("generateTemplates") {
Expand Down
7 changes: 6 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
version=3.22.0
plugin-name=VelocityVanish
plugin-name=VelocityVanish

# Hangar properties
paperVersion=1.8.9-1.20.1
foliaVersion=1.19.4-1.20.1
velocityVersion=3.2

0 comments on commit 3187438

Please sign in to comment.