Set up Hangar publishing
This commit is contained in:
parent
8cd76985ad
commit
afbb3bf3b9
|
@ -0,0 +1,25 @@
|
|||
name: Publish to Hangar
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
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 8
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 8
|
||||
check-latest: true
|
||||
- name: Publish
|
||||
env:
|
||||
HANGAR_TOKEN: ${{ secrets.HANGAR_TOKEN }}
|
||||
run: ./gradlew build publishAllPublicationsToHangar
|
54
build.gradle
54
build.gradle
|
@ -1,6 +1,9 @@
|
|||
import io.papermc.hangarpublishplugin.model.Platforms
|
||||
|
||||
plugins {
|
||||
id "java-library"
|
||||
id "maven-publish"
|
||||
id "io.papermc.hangar-publish-plugin" version "0.1.0"
|
||||
}
|
||||
|
||||
repositories {
|
||||
|
@ -55,3 +58,54 @@ tasks.withType(JavaCompile) {
|
|||
tasks.withType(Javadoc) {
|
||||
options.encoding = "UTF-8"
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
// Publishing
|
||||
|
||||
def latestCommitHash() {
|
||||
def byteOut = new ByteArrayOutputStream()
|
||||
exec {
|
||||
commandLine 'git', 'rev-parse', '--short', 'HEAD'
|
||||
standardOutput = byteOut
|
||||
}
|
||||
return byteOut.toString('UTF-8').trim()
|
||||
}
|
||||
|
||||
def latestCommitMessage() {
|
||||
def byteOut = new ByteArrayOutputStream()
|
||||
exec {
|
||||
commandLine 'git', 'log', '-1', '--pretty=%B'
|
||||
standardOutput = byteOut
|
||||
}
|
||||
return byteOut.toString('UTF-8').trim()
|
||||
}
|
||||
|
||||
def baseVersion = project.maven_version
|
||||
def isRelease = !baseVersion.contains('-')
|
||||
def suffixedVersion = isRelease ? baseVersion : baseVersion + "+" + System.getenv("GITHUB_RUN_NUMBER")
|
||||
def commitHash = latestCommitHash()
|
||||
def changelogContent = "[${commitHash}](https://github.com/ViaVersion/iaRewind-Legacy-Support/commit/${commitHash}) ${latestCommitMessage()}"
|
||||
hangarPublish {
|
||||
publications.register("plugin") {
|
||||
version.set(suffixedVersion)
|
||||
id.set("ViaRewindLegacySupport")
|
||||
channel.set(isRelease ? "Release" : "Snapshot")
|
||||
changelog.set(changelogContent)
|
||||
apiKey.set(System.getenv("HANGAR_TOKEN"))
|
||||
platforms {
|
||||
register(Platforms.PAPER) {
|
||||
jar.set(tasks.jar.archiveFile)
|
||||
platformVersions.set([property('mcVersionRange') as String])
|
||||
dependencies.hangar("ViaVersion") {
|
||||
required.set(true)
|
||||
}
|
||||
dependencies.hangar("ViaBackwards") {
|
||||
required.set(false)
|
||||
}
|
||||
dependencies.hangar("ViaRewind") {
|
||||
required.set(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,3 +6,5 @@ org.gradle.parallel=true
|
|||
# project
|
||||
maven_version=1.5.0-SNAPSHOT
|
||||
maven_group=com.viaversion
|
||||
|
||||
mcVersionRange=1.8-1.20.2
|
Loading…
Reference in New Issue