Skip to content

Commit 1ba7de7

Browse files
committed
测试 hangar 发布脚本
1 parent 9113d3a commit 1ba7de7

File tree

2 files changed

+70
-18
lines changed

2 files changed

+70
-18
lines changed

.github/workflows/main.yml

Lines changed: 40 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ on:
77

88
jobs:
99
build:
10-
# 配置权限
1110
permissions: write-all
1211
runs-on: ubuntu-latest
12+
outputs:
13+
release_tag: ${{ steps.set_tag.outputs.tag }}
1314
steps:
1415
- uses: actions/checkout@v3
1516
- name: "Set up JDK 21"
@@ -20,35 +21,57 @@ jobs:
2021
cache: gradle
2122
- name: "Build with Gradle"
2223
run: ./gradlew buildPlugin
23-
- name: "Copy jar to staging"
24+
- name: "Prepare release artifacts"
2425
run: |
25-
mkdir staging && cp build/libs/*.jar staging/
26-
- name: "Build & test"
27-
run: |
28-
TAG=$(echo $GITHUB_REF | sed 's/refs\/tags\///')
29-
echo "done!"
26+
mkdir -p staging
27+
cp build/libs/*.jar staging/
28+
- name: "Set release tag"
29+
id: set_tag
30+
run: echo "tag=${GITHUB_REF_NAME}" >> $GITHUB_ENV
31+
32+
github-release:
33+
needs: build
34+
runs-on: ubuntu-latest
35+
steps:
36+
- uses: actions/checkout@v3
3037
- name: "GitHub Release"
31-
uses: "marvinpinto/action-automatic-releases@latest"
38+
uses: marvinpinto/action-automatic-releases@latest
3239
with:
3340
repo_token: "${{ secrets.GITHUB_TOKEN }}"
34-
automatic_release_tag: "${{ steps.build.outputs.TAG }}"
41+
automatic_release_tag: "${{ needs.build.outputs.release_tag }}"
3542
prerelease: false
3643
files: |
37-
staging/*.jar
44+
build/libs/*.jar
45+
46+
modrinth-release:
47+
needs: build
48+
runs-on: ubuntu-latest
49+
steps:
50+
- uses: actions/checkout@v3
3851
- name: "Modrinth Release"
3952
uses: dsx137/modrinth-release-action@main
4053
env:
4154
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
4255
with:
43-
name: ${{ env.AUTOMATIC_RELEASES_TAG }}
56+
name: ${{ needs.build.outputs.release_tag }}
4457
project_id: vVZc7jAV
4558
loaders: bukkit,folia,paper,purpur,spigot
4659
game_versions: 1.20.1:1.20.6,1.21,1.21.1
47-
version_number: ${{ env.AUTOMATIC_RELEASES_TAG }}
60+
version_number: ${{ needs.build.outputs.release_tag }}
4861
files: |
49-
staging/*.jar
50-
changelog: "See https://github.com/ColdeZhang/Dominion/releases/tag/${{ env.AUTOMATIC_RELEASES_TAG }}"
51-
version_type: beta # or beta, alpha
62+
build/libs/*.jar
63+
changelog: "See https://github.com/ColdeZhang/Dominion/releases/tag/${{ needs.build.outputs.release_tag }}"
64+
version_type: beta
5265
featured: false
53-
updatable: false # default true, means updating existing version
54-
delete_old_files: false # default true
66+
updatable: false
67+
delete_old_files: false
68+
69+
hangar-release:
70+
needs: build
71+
runs-on: ubuntu-latest
72+
steps:
73+
- uses: actions/checkout@v3
74+
- name: "Hangar Release"
75+
env:
76+
HANGAR_TOKEN: ${{ secrets.HANGAR_API_TOKEN }}
77+
run: ./gradlew publishPluginPublicationToHangar --stacktrace

build.gradle.kts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
import io.papermc.hangarpublishplugin.model.Platforms
2+
13
plugins {
24
id("java")
35
id("com.github.johnrengelman.shadow") version "8.1.1"
6+
id("io.papermc.hangar-publish-plugin") version "0.1.2"
47
}
58

69
group = "cn.lunadeer"
7-
version = "2.6.9-beta"
10+
version = "2.6.10-beta"
811

912
java {
1013
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
@@ -41,6 +44,10 @@ allprojects {
4144

4245
tasks.processResources {
4346
outputs.upToDateWhen { false }
47+
// copy languages folder from PROJECT_DIR/languages to core/src/main/resources
48+
from(file("${projectDir}/languages")) {
49+
into("languages")
50+
}
4451
// replace @version@ in plugin.yml with project version
4552
filesMatching("**/plugin.yml") {
4653
filter {
@@ -70,4 +77,26 @@ tasks.shadowJar {
7077
tasks.register("buildPlugin") { // <<<< RUN THIS TASK TO BUILD PLUGIN
7178
dependsOn(tasks.clean)
7279
dependsOn(tasks.shadowJar)
80+
}
81+
82+
hangarPublish {
83+
publications.register("plugin") {
84+
version.set(project.version as String) // use project version as publication version
85+
id.set("Dominion")
86+
channel.set("Beta")
87+
changelog.set("See https://github.com/ColdeZhang/Dominion/releases/tag/v${project.version}")
88+
apiKey.set(System.getenv("HANGAR_TOKEN"))
89+
// register platforms
90+
platforms {
91+
register(Platforms.PAPER) {
92+
jar.set(tasks.shadowJar.flatMap { it.archiveFile })
93+
println("ShadowJar: ${tasks.shadowJar.flatMap { it.archiveFile }}")
94+
platformVersions.set(listOf("1.20.1-1.20.6","1.21.x"))
95+
}
96+
}
97+
}
98+
}
99+
100+
tasks.named("publishPluginPublicationToHangar") {
101+
dependsOn(tasks.named("jar"))
73102
}

0 commit comments

Comments
 (0)