mirror of
https://github.com/ViaVersion/ViaBackwards.git
synced 2024-12-21 16:47:57 +01:00
Add Hangar publishing
This commit is contained in:
parent
0d147653f3
commit
70725d4aaf
26
.github/workflows/publish.yml
vendored
Normal file
26
.github/workflows/publish.yml
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
name: Publish to Hangar and Modrinth
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- dev
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
if: github.repository_owner == 'ViaVersion'
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v3
|
||||
- name: Validate Gradle Wrapper
|
||||
uses: gradle/wrapper-validation-action@v1
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 17
|
||||
- name: Publish
|
||||
env:
|
||||
HANGAR_TOKEN: ${{ secrets.HANGAR_TOKEN }}
|
||||
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
|
||||
run: ./gradlew publishAllPublicationsToHangar # add 'modrinth' after it is approved
|
@ -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) {
|
||||
sourceCompatibility = JavaVersion.toVersion(version)
|
||||
targetCompatibility = JavaVersion.toVersion(version)
|
||||
|
@ -5,7 +5,7 @@ plugins {
|
||||
|
||||
allprojects {
|
||||
group = "com.viaversion"
|
||||
version = "4.8.0-23w32a-SNAPSHOT"
|
||||
version = property("projectVersion") as String // from gradle.properties
|
||||
description = "Allow older clients to join newer server versions."
|
||||
}
|
||||
|
||||
|
5
gradle.properties
Normal file
5
gradle.properties
Normal file
@ -0,0 +1,5 @@
|
||||
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.10-1.20.1
|
||||
waterfallVersion=1.20
|
||||
velocityVersion=3.2
|
@ -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,69 @@ tasks {
|
||||
}
|
||||
|
||||
publishShadowJar()
|
||||
|
||||
val branch = rootProject.branchName()
|
||||
val isMainBranch = branch == "master"
|
||||
val ver = (project.version as String) + "+" + System.getenv("GITHUB_RUN_NUMBER")
|
||||
val changelogContent = rootProject.lastCommitMessage()
|
||||
modrinth {
|
||||
val mcVersions: List<String> = (property("mcVersions") as String)
|
||||
.split(",")
|
||||
.map { it.trim() }
|
||||
token.set(System.getenv("MODRINTH_TOKEN"))
|
||||
projectId.set("viabackwards")
|
||||
versionType.set(if (isMainBranch) "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")
|
||||
}
|
||||
}
|
||||
|
||||
if (isMainBranch) { // Don't spam releases until Hangar has per channel notifications
|
||||
hangarPublish {
|
||||
publications.register("plugin") {
|
||||
version.set(ver)
|
||||
namespace("ViaVersion", "ViaBackwards")
|
||||
channel.set(if (isMainBranch) "Snapshot" else "Alpha")
|
||||
changelog.set(changelogContent)
|
||||
apiKey.set(System.getenv("HANGAR_TOKEN"))
|
||||
platforms {
|
||||
register(Platforms.PAPER) {
|
||||
jar.set(tasks.shadowJar.flatMap { it.archiveFile })
|
||||
platformVersions.set(listOf(property("mcVersionRange") as String))
|
||||
dependencies {
|
||||
hangar("ViaVersion", "ViaVersion") {
|
||||
required.set(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
register(Platforms.VELOCITY) {
|
||||
jar.set(tasks.shadowJar.flatMap { it.archiveFile })
|
||||
platformVersions.set(listOf(property("velocityVersion") as String))
|
||||
dependencies {
|
||||
hangar("ViaVersion", "ViaVersion") {
|
||||
required.set(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
register(Platforms.WATERFALL) {
|
||||
jar.set(tasks.shadowJar.flatMap { it.archiveFile })
|
||||
platformVersions.set(listOf(property("waterfallVersion") as String))
|
||||
dependencies {
|
||||
hangar("ViaVersion", "ViaVersion") {
|
||||
required.set(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user