Skip to content

Commit

Permalink
added modrinth publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
NonSwag committed Jun 27, 2024
1 parent 6f0a67f commit 4ccc202
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 4 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/modrinth-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Modrinth Publish

on:
release:
types:
- prereleased
- released

jobs:
build:
env:
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Publish with Gradle to Modrinth
uses: gradle/actions/setup-gradle@v3
with:
arguments: modrinth
22 changes: 19 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ plugins {
id("io.github.goooler.shadow") version "8.1.7"
id("net.minecrell.plugin-yml.paper") version "0.6.0"
id("io.papermc.hangar-publish-plugin") version "0.1.2"
id("com.modrinth.minotaur") version "2.+"
}

group = "net.thenextlvl"
Expand Down Expand Up @@ -163,6 +164,10 @@ paper {
val versionString: String = project.version as String
val isRelease: Boolean = !versionString.contains("-pre")

val versions: List<String> = (property("gameVersions") as String)
.split(",")
.map { it.trim() }

hangarPublish { // docs - https://docs.papermc.io/misc/hangar-publishing
publications.register("plugin") {
id.set("Tweaks")
Expand All @@ -171,9 +176,6 @@ hangarPublish { // docs - https://docs.papermc.io/misc/hangar-publishing
apiKey.set(System.getenv("HANGAR_API_TOKEN"))
platforms.register(Platforms.PAPER) {
jar.set(tasks.shadowJar.flatMap { it.archiveFile })
val versions: List<String> = (property("paperVersion") as String)
.split(",")
.map { it.trim() }
platformVersions.set(versions)
dependencies {
url("LuckPerms", "https://luckperms.net/") {
Expand All @@ -183,3 +185,17 @@ hangarPublish { // docs - https://docs.papermc.io/misc/hangar-publishing
}
}
}

modrinth {
token.set(System.getenv("MODRINTH_TOKEN"))
projectId.set("HLkJsjy0")
versionType = if (isRelease) "release" else "beta"
uploadFile.set(tasks.shadowJar.flatMap { it.archiveFile })
gameVersions.set(versions)
loaders.add("paper")
loaders.add("folia")
syncBodyFrom.set(rootProject.file("README.md").readText())
dependencies {
optional.project("luckperms")
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
kotlin.code.style=official
paperVersion=1.20.5
gameVersions=1.20.6

0 comments on commit 4ccc202

Please sign in to comment.