Skip to content

Commit

Permalink
chore: add support for publishing to papermc hangar
Browse files Browse the repository at this point in the history
  • Loading branch information
kernitus committed Oct 20, 2024
1 parent e1f3329 commit f05edcb
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 13 deletions.
35 changes: 22 additions & 13 deletions .github/workflows/build-upload-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,20 @@ jobs:
else
./gradlew clean build
fi
- name: Upload Artifact to GitHub Release
if: ${{ github.event_name == 'release' }}
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./build/libs/OldCombatMechanics.jar
asset_name: OldCombatMechanics-${{ github.event.release.tag_name }}.jar
asset_content_type: application/java-archive

- name: Read game versions from gradle.properties
run: |
GAME_VERSIONS=$(grep ^gameVersions gradle.properties | cut -d'=' -f2-)
echo "GAME_VERSIONS=$GAME_VERSIONS" >> $GITHUB_ENV
- name: Upload to dev.bukkit.org
if: ${{ github.event_name == 'release' }}
Expand All @@ -44,19 +58,14 @@ jobs:
changelog: ${{ github.event.release.body }}
changelog_type: markdown
display_name: ${{ github.event.release.tag_name }}
game_versions: >
1.21,1.20.6,1.20.5,1.20.4,1.20.3,1.20.2,1.20.1,1.20,
1.19.4,1.19.3,1.19.2,1.19.1,1.19,
1.18.2,1.18.1,1.18,1.17,1.16,1.15,
1.14,1.13,1.12,1.11,1.10,1.9
game_versions: ${{ env.GAME_VERSIONS }}
release_type: 'release'
file_path: './build/libs/OldCombatMechanics.jar'

- name: Upload Artifact to GitHub Release
if: ${{ github.event_name == 'release' }}
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./build/libs/OldCombatMechanics.jar
asset_name: OldCombatMechanics-${{ github.event.release.tag_name }}.jar
asset_content_type: application/java-archive

- name: Publish to Hangar
env:
HANGAR_TOKEN: ${{ secrets.HANGAR_API_TOKEN }}
HANGAR_CHANGELOG: ${{ github.event.release.body }}
run: ./gradlew build publishPluginPublicationToHangar --stacktrace

24 changes: 24 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ plugins {
// For ingametesting
//id("io.papermc.paperweight.userdev") version "1.5.10"
idea
id("io.papermc.hangar-publish-plugin") version "0.1.2"
}

// Make sure javadocs are available to IDE
Expand Down Expand Up @@ -113,3 +114,26 @@ tasks.assemble {
//dependsOn("reobfJar")
dependsOn("shadowJar")
}

hangarPublish {
publications.register("plugin") {
version.set(project.version as String)
channel.set("Release")
id.set("OldCombatMechanics")
apiKey.set(System.getenv("HANGAR_API_TOKEN"))
changelog.set(System.getenv("HANGAR_CHANGELOG") ?: "No changelog provided")

platforms {
register(Platforms.PAPER) {
// Use shadowJar output
jar.set(tasks.shadowJar.flatMap { it.archiveFile })

// Set platform versions from gradle.properties file
val versions: List<String> = (property("gameVersion") as String)
.split(",")
.map { it.trim() }
platformVersions.set(gameVersions)
}
}
}
}
8 changes: 8 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.

gameVersions=1.21,1.20.6,1.20.5,1.20.4,1.20.3,1.20.2,1.20.1,1.20,\
1.19.4,1.19.3,1.19.2,1.19.1,1.19,\
1.18.2,1.18.1,1.18,1.17,1.16,1.15,\
1.14,1.13,1.12,1.11,1.10,1.9

0 comments on commit f05edcb

Please sign in to comment.