Skip to content

Commit

Permalink
测试 hangar 发布脚本
Browse files Browse the repository at this point in the history
  • Loading branch information
ColdeZhang committed Sep 11, 2024
1 parent 9113d3a commit 1ba7de7
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 18 deletions.
57 changes: 40 additions & 17 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ on:

jobs:
build:
# 配置权限
permissions: write-all
runs-on: ubuntu-latest
outputs:
release_tag: ${{ steps.set_tag.outputs.tag }}
steps:
- uses: actions/checkout@v3
- name: "Set up JDK 21"
Expand All @@ -20,35 +21,57 @@ jobs:
cache: gradle
- name: "Build with Gradle"
run: ./gradlew buildPlugin
- name: "Copy jar to staging"
- name: "Prepare release artifacts"
run: |
mkdir staging && cp build/libs/*.jar staging/
- name: "Build & test"
run: |
TAG=$(echo $GITHUB_REF | sed 's/refs\/tags\///')
echo "done!"
mkdir -p staging
cp build/libs/*.jar staging/
- name: "Set release tag"
id: set_tag
run: echo "tag=${GITHUB_REF_NAME}" >> $GITHUB_ENV

github-release:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: "GitHub Release"
uses: "marvinpinto/action-automatic-releases@latest"
uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "${{ steps.build.outputs.TAG }}"
automatic_release_tag: "${{ needs.build.outputs.release_tag }}"
prerelease: false
files: |
staging/*.jar
build/libs/*.jar
modrinth-release:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: "Modrinth Release"
uses: dsx137/modrinth-release-action@main
env:
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
with:
name: ${{ env.AUTOMATIC_RELEASES_TAG }}
name: ${{ needs.build.outputs.release_tag }}
project_id: vVZc7jAV
loaders: bukkit,folia,paper,purpur,spigot
game_versions: 1.20.1:1.20.6,1.21,1.21.1
version_number: ${{ env.AUTOMATIC_RELEASES_TAG }}
version_number: ${{ needs.build.outputs.release_tag }}
files: |
staging/*.jar
changelog: "See https://github.com/ColdeZhang/Dominion/releases/tag/${{ env.AUTOMATIC_RELEASES_TAG }}"
version_type: beta # or beta, alpha
build/libs/*.jar
changelog: "See https://github.com/ColdeZhang/Dominion/releases/tag/${{ needs.build.outputs.release_tag }}"
version_type: beta
featured: false
updatable: false # default true, means updating existing version
delete_old_files: false # default true
updatable: false
delete_old_files: false

hangar-release:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: "Hangar Release"
env:
HANGAR_TOKEN: ${{ secrets.HANGAR_API_TOKEN }}
run: ./gradlew publishPluginPublicationToHangar --stacktrace
31 changes: 30 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import io.papermc.hangarpublishplugin.model.Platforms

plugins {
id("java")
id("com.github.johnrengelman.shadow") version "8.1.1"
id("io.papermc.hangar-publish-plugin") version "0.1.2"
}

group = "cn.lunadeer"
version = "2.6.9-beta"
version = "2.6.10-beta"

java {
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
Expand Down Expand Up @@ -41,6 +44,10 @@ allprojects {

tasks.processResources {
outputs.upToDateWhen { false }
// copy languages folder from PROJECT_DIR/languages to core/src/main/resources
from(file("${projectDir}/languages")) {
into("languages")
}
// replace @version@ in plugin.yml with project version
filesMatching("**/plugin.yml") {
filter {
Expand Down Expand Up @@ -70,4 +77,26 @@ tasks.shadowJar {
tasks.register("buildPlugin") { // <<<< RUN THIS TASK TO BUILD PLUGIN
dependsOn(tasks.clean)
dependsOn(tasks.shadowJar)
}

hangarPublish {
publications.register("plugin") {
version.set(project.version as String) // use project version as publication version
id.set("Dominion")
channel.set("Beta")
changelog.set("See https://github.com/ColdeZhang/Dominion/releases/tag/v${project.version}")
apiKey.set(System.getenv("HANGAR_TOKEN"))
// register platforms
platforms {
register(Platforms.PAPER) {
jar.set(tasks.shadowJar.flatMap { it.archiveFile })
println("ShadowJar: ${tasks.shadowJar.flatMap { it.archiveFile }}")
platformVersions.set(listOf("1.20.1-1.20.6","1.21.x"))
}
}
}
}

tasks.named("publishPluginPublicationToHangar") {
dependsOn(tasks.named("jar"))
}

0 comments on commit 1ba7de7

Please sign in to comment.