Skip to content

Commit

Permalink
Hello modrinth 😎
Browse files Browse the repository at this point in the history
  • Loading branch information
kennytv committed Aug 11, 2023
1 parent 70725d4 commit 796f81f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ jobs:
env:
HANGAR_TOKEN: ${{ secrets.HANGAR_TOKEN }}
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
run: ./gradlew publishAllPublicationsToHangar # add 'modrinth' after it is approved
run: ./gradlew modrinth publishAllPublicationsToHangar
9 changes: 9 additions & 0 deletions build-logic/src/main/kotlin/extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ fun Project.branchName(): String {
return byteOut.toString(Charsets.UTF_8.name()).trim()
}

fun Project.parseMinecraftSnapshotVersion(version: String): String? {
val separatorIndex = version.indexOf('-')
val lastSeparatorIndex = version.lastIndexOf('-')
if (separatorIndex == -1 || separatorIndex == lastSeparatorIndex) {
return null
}
return version.substring(separatorIndex + 1, lastSeparatorIndex)
}

fun JavaPluginExtension.javaTarget(version: Int) {
sourceCompatibility = JavaVersion.toVersion(version)
targetCompatibility = JavaVersion.toVersion(version)
Expand Down
10 changes: 9 additions & 1 deletion universal/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,26 @@ val isMainBranch = branch == "master"
val ver = (project.version as String) + "+" + System.getenv("GITHUB_RUN_NUMBER")
val changelogContent = rootProject.lastCommitMessage()
modrinth {
val snapshotVersion = rootProject.parseMinecraftSnapshotVersion(project.version as String)
val mcVersions: List<String> = (property("mcVersions") as String)
.split(",")
.map { it.trim() }
.let { if (snapshotVersion != null) it + snapshotVersion else it }

token.set(System.getenv("MODRINTH_TOKEN"))
projectId.set("viabackwards")
versionType.set(if (isMainBranch) "beta" else "alpha")
versionNumber.set(ver)
versionName.set("[$branch] $ver")
versionName.set(ver)
changelog.set(changelogContent)
uploadFile.set(tasks.shadowJar.flatMap { it.archiveFile })
gameVersions.set(mcVersions)
loaders.add("fabric")
loaders.add("paper")
loaders.add("folia")
loaders.add("velocity")
loaders.add("bungeecord")
loaders.add("sponge")
autoAddDependsOn.set(false)
detectLoaders.set(false)
dependencies {
Expand Down

0 comments on commit 796f81f

Please sign in to comment.