GH-310 Add Hangar publishing workflow and configure build script for Hangar integration (#312)
* GH-310 Add Hangar publishing workflow and configure build script for Hangar integration * Expand supported Paper versions in `gradle.properties` to include versions 1.17 through 1.21.11.
This commit is contained in:
1 parent
1af5710ac9
commit
1c2797225a
3 files changed
+71
-4
No files matched your search
@@ -0,0 +1,34 @@
|
||||
name: Publish to Hangar
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
if: (github.event_name == 'push' && !contains(github.event.head_commit.message, '[ci skip]')) || github.event_name == 'release'
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: '21'
|
||||
distribution: 'temurin'
|
||||
|
||||
- name: Setup Gradle
|
||||
uses: gradle/actions/setup-gradle@v4
|
||||
|
||||
- name: Publish to Hangar
|
||||
run: ./gradlew :eternalcombat-plugin:publishPluginPublicationToHangar
|
||||
env:
|
||||
HANGAR_API_TOKEN: ${{ secrets.HANGAR_API_TOKEN }}
|
||||
GITHUB_EVENT_NAME: ${{ github.event_name }}
|
||||
CHANGELOG: ${{ github.event_name == 'release' && github.event.release.body || github.event.head_commit.message }}
|
||||
@@ -1,4 +1,5 @@
|
||||
import net.minecrell.pluginyml.bukkit.BukkitPluginDescription
|
||||
import io.papermc.hangarpublishplugin.model.Platforms
|
||||
|
||||
plugins {
|
||||
`eternalcombat-java`
|
||||
@@ -8,6 +9,7 @@ plugins {
|
||||
id("com.gradleup.shadow")
|
||||
id("xyz.jpenilla.run-paper")
|
||||
id("com.modrinth.minotaur") version "2.8.10"
|
||||
id("io.papermc.hangar-publish-plugin") version "0.1.2"
|
||||
}
|
||||
|
||||
val buildNumber = providers.environmentVariable("GITHUB_RUN_NUMBER").orNull
|
||||
@@ -38,20 +40,48 @@ val changelogText = providers.environmentVariable("CHANGELOG").orElse(providers.
|
||||
commandLine("git", "log", "-1", "--format=%B")
|
||||
}.standardOutput.asText)
|
||||
|
||||
logger.lifecycle("Minotaur: Building version: $version")
|
||||
logger.lifecycle("Building version: $version")
|
||||
|
||||
val paperVersions = (property("paperVersion") as String)
|
||||
.split(",")
|
||||
.map { it.trim() }
|
||||
|
||||
val hangarToken = providers.environmentVariable("HANGAR_API_TOKEN")
|
||||
.orElse(providers.gradleProperty("hangarToken"))
|
||||
|
||||
val projectVersion = project.version.toString()
|
||||
val releaseChannel = if (isRelease) "Release" else "Snapshot"
|
||||
val shadowJarTask = tasks.shadowJar
|
||||
|
||||
modrinth {
|
||||
token.set(providers.environmentVariable("MODRINTH_TOKEN"))
|
||||
projectId.set("eternalcombat")
|
||||
versionNumber.set(project.version.toString())
|
||||
versionNumber.set(projectVersion)
|
||||
versionType.set(if (isRelease) "release" else "beta")
|
||||
uploadFile.set(tasks.shadowJar)
|
||||
gameVersions.addAll(listOf("1.19.4", "1.20.1", "1.20.4", "1.20.6", "1.21", "1.21.1"))
|
||||
uploadFile.set(shadowJarTask)
|
||||
gameVersions.addAll(paperVersions)
|
||||
loaders.addAll(listOf("paper", "spigot", "folia", "purpur"))
|
||||
changelog.set(changelogText)
|
||||
syncBodyFrom.set(rootProject.file("README.md").readText())
|
||||
}
|
||||
|
||||
|
||||
hangarPublish {
|
||||
publications.register("plugin") {
|
||||
version.set(projectVersion)
|
||||
channel.set(releaseChannel)
|
||||
changelog.set(changelogText)
|
||||
id.set("eternalcombat")
|
||||
apiKey.set(hangarToken)
|
||||
platforms {
|
||||
register(Platforms.PAPER) {
|
||||
jar.set(shadowJarTask.flatMap { it.archiveFile })
|
||||
platformVersions.set(paperVersions)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
configurations.all {
|
||||
resolutionStrategy {
|
||||
eachDependency {
|
||||
|
||||
@@ -2,3 +2,6 @@ org.gradle.parallel=true
|
||||
org.gradle.caching=true
|
||||
org.gradle.configuration-cache=true
|
||||
org.gradle.configuration-cache.parallel=true
|
||||
|
||||
# Platforms
|
||||
paperVersion=1.17,1.17.1,1.18,1.18.1,1.18.2,1.19,1.19.1,1.19.2,1.19.3,1.19.4,1.20,1.20.1,1.20.2,1.20.3,1.20.4,1.20.5,1.20.6,1.21,1.21.1,1.21.2,1.21.3,1.21.4,1.21.5,1.21.6,1.21.7,1.21.8,1.21.9,1.21.10,1.21.11
|
||||
Reference in new issue
Block a user