Skip to content

Commit bfd7359

Browse files
committed
added hangar task
1 parent eb2886e commit bfd7359

2 files changed

Lines changed: 77 additions & 2 deletions

File tree

dist/build.gradle.kts

Lines changed: 76 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
import io.papermc.hangarpublishplugin.model.Platforms
2+
import java.net.URI
3+
14
plugins {
25
id("com.gradleup.shadow") version "9.2.2"
36
id("com.modrinth.minotaur") version "2.+"
7+
id("io.papermc.hangar-publish-plugin") version "0.1.4"
48
java
59
}
610

@@ -36,16 +40,41 @@ dependencies {
3640
}
3741

3842
val pluginVersion: Provider<String> = providers.gradleProperty("pluginVersion")
43+
val modrinthProjectSlug = "commandbridge"
44+
45+
val modrinthDownloadUrl: Provider<String> = pluginVersion.map { version ->
46+
val versionMetadata = URI("https://api.modrinth.com/v2/project/$modrinthProjectSlug/version/$version")
47+
.toURL()
48+
.readText()
49+
50+
Regex("\"url\":\"(https://cdn\\.modrinth\\.com/data/[^\"]+)\"")
51+
.find(versionMetadata)
52+
?.groupValues
53+
?.get(1)
54+
?: error("Could not resolve Modrinth download URL for version $version")
55+
}
56+
57+
val supportedMinecraftVersions = listOf(
58+
"1.20", "1.20.1", "1.20.2", "1.20.3", "1.20.4", "1.20.5", "1.20.6",
59+
"1.21", "1.21.1", "1.21.2", "1.21.3", "1.21.4", "1.21.5", "1.21.6",
60+
"1.21.7", "1.21.8", "1.21.9", "1.21.10", "1.21.11"
61+
)
62+
63+
val supportedVelocityVersions = listOf(
64+
"3.4","3.4.0","3.5"
65+
)
66+
67+
val releaseChannel: Provider<String> = providers.gradleProperty("releaseChannel")
3968

4069
modrinth {
4170
token.set(System.getenv("MODRINTH_TOKEN"))
4271
projectId.set("commandbridge")
4372
versionNumber.set(pluginVersion)
4473
versionName.set(pluginVersion.map { "CommandBridge $it" })
4574
changelog.set(rootProject.file("CHANGELOG.md").readText())
46-
versionType.set("beta")
75+
versionType.set(releaseChannel)
4776
uploadFile.set(tasks.shadowJar)
48-
gameVersions.addAll("1.20", "1.20.1", "1.20.2", "1.20.3", "1.20.4", "1.20.5", "1.20.6", "1.21", "1.21.1", "1.21.2", "1.21.3", "1.21.4", "1.21.5", "1.21.6", "1.21.7", "1.21.8", "1.21.9", "1.21.10", "1.21.11")
77+
gameVersions.addAll(supportedMinecraftVersions)
4978
loaders.addAll("folia", "paper", "bukkit", "spigot", "purpur", "velocity")
5079
dependencies {
5180
required.project("commandapi")
@@ -55,6 +84,50 @@ modrinth {
5584
}
5685
}
5786

87+
hangarPublish {
88+
publications.register("plugin") {
89+
version = pluginVersion.get()
90+
channel = if (releaseChannel.get().contains("beta")) "Beta" else "Release"
91+
id = "CommandBridge"
92+
changelog = rootProject.file("CHANGELOG.md").readText()
93+
apiKey = System.getenv("HANGAR_TOKEN")
94+
95+
platforms {
96+
register(Platforms.PAPER) {
97+
url.set(modrinthDownloadUrl)
98+
platformVersions = supportedMinecraftVersions
99+
dependencies {
100+
hangar("CommandAPI") {
101+
required.set(true)
102+
}
103+
hangar("PAPIProxyBridge") {
104+
required.set(false)
105+
}
106+
hangar("PlaceholderAPI") {
107+
required.set(false)
108+
}
109+
}
110+
}
111+
register(Platforms.VELOCITY) {
112+
url.set(modrinthDownloadUrl)
113+
platformVersions = supportedVelocityVersions
114+
115+
dependencies {
116+
hangar("CommandAPI") {
117+
required.set(true)
118+
}
119+
hangar("PAPIProxyBridge") {
120+
required.set(false)
121+
}
122+
url("PacketEvents","https://modrinth.com/plugin/packetevents") {
123+
required.set(false)
124+
}
125+
}
126+
}
127+
}
128+
}
129+
}
130+
58131

59132
tasks {
60133
jar { enabled = false }
@@ -122,5 +195,6 @@ tasks {
122195
}
123196

124197
register("dev") { dependsOn(copyToVelocityPlugins, copyToPaperPlugins) }
198+
register("hangar") { dependsOn("publishPluginPublicationToHangar") }
125199
build { dependsOn(shadowJar) }
126200
}

gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
org.gradle.configuration-cache=true
22
pluginVersion=3.1.0
3+
releaseChannel="beta"
34

0 commit comments

Comments
 (0)