Skip to content

Commit

Permalink
build: Setup automatic Hangar and Modrinth publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
jpenilla committed Mar 18, 2023
1 parent e497001 commit 51e5998
Show file tree
Hide file tree
Showing 13 changed files with 116 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@ on:
branches: [ "**" ]
tags-ignore: [ "**" ]
pull_request:
release:
types: [ released ]

jobs:
call-build:
uses: "jpenilla/actions/.github/workflows/shared-ci.yml@master"
secrets: inherit
with:
artifacts-path: 'build/libs/*.jar'
modrinth-publish: true
hangar-publish: true
loom: true
2 changes: 2 additions & 0 deletions build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ dependencies {
implementation(libs.indraLicenser)
implementation(libs.shadow)
implementation(libs.testLogger)
implementation(libs.minotaur)
implementation(libs.hangarPublishPlugin)

// https://github.com/gradle/gradle/issues/15383#issuecomment-779893192
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
Expand Down
7 changes: 3 additions & 4 deletions build-logic/src/main/kotlin/MiniMOTDPlatformExtension.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import org.gradle.api.Project
import org.gradle.api.provider.Property
import org.gradle.api.tasks.bundling.AbstractArchiveTask
import org.gradle.kotlin.dsl.property

abstract class MiniMOTDPlatformExtension(project: Project) {
val jarTask: Property<AbstractArchiveTask> = project.objects.property()
interface MiniMOTDPlatformExtension {
val jarTask: Property<AbstractArchiveTask>
val hangar: Property<Boolean>
}
23 changes: 23 additions & 0 deletions build-logic/src/main/kotlin/extensions.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,33 @@
import net.kyori.indra.git.IndraGitExtension
import org.gradle.accessors.dm.LibrariesForLibs
import org.gradle.api.Project
import org.gradle.api.provider.Provider
import org.gradle.kotlin.dsl.the

fun Project.lastCommitHash(): String =
the<IndraGitExtension>().commit()?.name?.substring(0, 7) ?: "unknown"

val Project.libs: LibrariesForLibs
get() = the()

val Project.releaseNotes: Provider<String>
get() = providers.environmentVariable("RELEASE_NOTES")

val Project.minecraftVersion
get() = libs.versions.minecraft.get()

val bukkitVersions = listOf(
"1.8.8",
"1.8.9",
"1.9.4",
"1.10.2",
"1.11.2",
"1.12.2",
"1.13.2",
"1.14.4",
"1.15.2",
"1.16.5",
"1.17.1",
"1.18.2",
"1.19.4"
)
32 changes: 32 additions & 0 deletions build-logic/src/main/kotlin/minimotd.build-logic.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
import io.papermc.hangarpublishplugin.model.Platforms

plugins {
base
id("io.papermc.hangar-publish-plugin")
}

fun jar(platform: String) = project(":minimotd-$platform")
.the<MiniMOTDPlatformExtension>().jarTask.flatMap { it.archiveFile }

hangarPublish.publications.register("plugin") {
version.set(project.version as String)
namespace("jmp", "MiniMOTD")
channel.set("Release")
changelog.set(releaseNotes)
apiKey.set(providers.environmentVariable("HANGAR_UPLOAD_KEY"))
platforms {
register(Platforms.PAPER) {
jar.set(jar("bukkit"))
val vers = bukkitVersions.toMutableList()
vers -= "1.8.8"
vers -= "1.8.9"
vers += "1.8"
platformVersions.addAll(vers)
}
register(Platforms.VELOCITY) {
jar.set(jar("velocity"))
platformVersions.addAll("3.2")
}
register(Platforms.WATERFALL) {
jar.set(jar("bungeecord"))
platformVersions.addAll("1.19")
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
plugins {
id("minimotd.base-conventions")
id("net.kyori.indra.git")
id("com.modrinth.minotaur")
}

val platformExtension = extensions.create<MiniMOTDPlatformExtension>("miniMOTDPlatform", project)
val platformExtension = extensions.create<MiniMOTDPlatformExtension>("miniMOTDPlatform")

tasks {
val copyJar = register<FileCopyTask>("copyJar") {
Expand All @@ -16,3 +17,11 @@ tasks {
dependsOn(copyJar)
}
}

modrinth {
projectId.set("16vhQOQN")
versionType.set("release")
file.set(platformExtension.jarTask.flatMap { it.archiveFile })
changelog.set(releaseNotes)
token.set(providers.environmentVariable("MODRINTH_TOKEN"))
}
16 changes: 13 additions & 3 deletions gradle/libs.versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ plugins:
xyz.jpenilla.run-waterfall: *run-task

versions:
minotaur: 2.7.5
hangarPublishPlugin: 0.0.4
indra: 3.0.1
shadow: 8.1.0
testLoggerPlugin: 3.2.0
Expand All @@ -30,7 +32,7 @@ versions:
waterfallApi: 1.16-R0.4-SNAPSHOT
fabricApi: 0.76.0+1.19.4
fabricLoader: 0.14.17
fabricMinecraft: 1.19.4
minecraft: 1.19.4
spongeApi7: 7.2.0
velocityApi: 3.1.2-SNAPSHOT
jupiterEngine: 5.9.2
Expand Down Expand Up @@ -136,10 +138,10 @@ dependencies:
group: net.fabricmc
name: fabric-loader
version: { ref: fabricLoader }
fabricMinecraft:
minecraft:
group: com.mojang
name: minecraft
version: { ref: fabricMinecraft }
version: { ref: minecraft }

spongeApi7:
group: org.spongepowered
Expand Down Expand Up @@ -173,5 +175,13 @@ dependencies:
group: com.adarshr
name: gradle-test-logger-plugin
version: { ref: testLoggerPlugin }
minotaur:
group: com.modrinth.minotaur
name: Minotaur
version: { ref: minotaur }
hangarPublishPlugin:
group: io.papermc
name: hangar-publish-plugin
version: { ref: hangarPublishPlugin }

bundles:
6 changes: 5 additions & 1 deletion platform/bukkit/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dependencies {

tasks {
runServer {
minecraftVersion("1.19.3")
minecraftVersion(minecraftVersion)
}
shadowJar {
platformRelocation("bukkit", "xyz.jpenilla.minimotd.common")
Expand All @@ -42,3 +42,7 @@ bukkit {
}
}
}

modrinth {
gameVersions.addAll(bukkitVersions)
}
4 changes: 4 additions & 0 deletions platform/bungeecord/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ bungee {
main = "xyz.jpenilla.minimotd.bungee.MiniMOTDPlugin"
author = "jmp"
}

modrinth {
gameVersions.addAll(minecraftVersion)
}
4 changes: 1 addition & 3 deletions platform/fabric/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ plugins {

val shade: Configuration by configurations.creating

val minecraftVersion = libs.versions.fabricMinecraft.get()

dependencies {
minecraft(libs.fabricMinecraft)
minecraft(libs.minecraft)
mappings(loom.officialMojangMappings())
modImplementation(libs.fabricLoader)
modImplementation(libs.fabricApi)
Expand Down
5 changes: 5 additions & 0 deletions platform/sponge7/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,8 @@ tasks {
commonRelocation("org.bstats")
}
}

modrinth {
loaders.add("sponge")
gameVersions.add("1.12.2")
}
9 changes: 9 additions & 0 deletions platform/sponge8/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,12 @@ tasks {
}
}
}

modrinth {
gameVersions.addAll(
"1.16.5",
"1.17.1",
"1.18.2",
"1.19.4"
)
}
4 changes: 4 additions & 0 deletions platform/velocity/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,7 @@ blossom {
replaceToken("\${$k}", v, file)
}
}

modrinth {
gameVersions.addAll(minecraftVersion)
}

0 comments on commit 51e5998

Please sign in to comment.