Skip to content

Commit

Permalink
Add CF publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
NotRyken committed Jun 26, 2024
1 parent 2f8112d commit edf7ee1
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 16 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ jobs:
if: ${{ runner.os != 'Windows' }}
run: chmod +x ./gradlew
- name: Build
run: ./gradlew build neoforge:githubRelease fabric:githubRelease --stacktrace
run: ./gradlew build neoforge:githubRelease neoforge:modrinth neoforge:curseforge fabric:githubRelease fabric:modrinth fabric:curseforge --stacktrace
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }}
- name: Capture build artifacts
if: ${{ runner.os == 'Linux' && matrix.java == '21' }}
uses: actions/upload-artifact@v4
Expand Down
59 changes: 48 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import com.modrinth.minotaur.dependencies.ModDependency

plugins {
id("java")
id("java-library")
id("idea")
id("maven-publish")
id("org.jetbrains.gradle.plugin.idea-ext") version("${ideaext_version}") // Required for NeoGradle
id("com.modrinth.minotaur") version("${minotaur_version}")
id("net.darkhax.curseforgegradle") version("${curseforgegradle_version}")
id("com.github.breadmoirai.github-release") version("${githubrelease_version}")
id("org.ajoberstar.grgit.service") version("${grgitservice_version}")
}
Expand Down Expand Up @@ -134,19 +133,19 @@ subprojects {
gameVersions = project.property("release_game_versions_${name}").split(",") as List

def deps = []
if (project.hasProperty("release_required_dep_ids_${name}")) {
project.property("release_required_dep_ids_${name}").split(",").each { String id ->
deps << new ModDependency(id, "required")
if (project.hasProperty("release_required_dep_ids_${name}_mr")) {
project.property("release_required_dep_ids_${name}_mr").split(",").each { String id ->
deps << new com.modrinth.minotaur.dependencies.ModDependency(id, "required")
}
}
if (project.hasProperty("release_optional_dep_ids_${name}")) {
project.property("release_optional_dep_ids_${name}").split(",").each { String id ->
deps << new ModDependency(id, "optional")
if (project.hasProperty("release_optional_dep_ids_${name}_mr")) {
project.property("release_optional_dep_ids_${name}_mr").split(",").each { String id ->
deps << new com.modrinth.minotaur.dependencies.ModDependency(id, "optional")
}
}
if (project.hasProperty("release_incompatible_dep_ids_${name}")) {
project.property("release_incompatible_dep_ids_${name}").split(",").each { String id ->
deps << new ModDependency(id, "incompatible")
if (project.hasProperty("release_incompatible_dep_ids_${name}_mr")) {
project.property("release_incompatible_dep_ids_${name}_mr").split(",").each { String id ->
deps << new com.modrinth.minotaur.dependencies.ModDependency(id, "incompatible")
}
}
dependencies = deps
Expand All @@ -156,6 +155,44 @@ subprojects {
tasks.modrinth.dependsOn(build, tasks.modrinthSyncBody)
tasks.modrinthSyncBody.onlyIf { System.getenv().MODRINTH_TOKEN }

task curseforge(type: net.darkhax.curseforgegradle.TaskPublishCurseForge) {
apiToken = System.getenv().CURSEFORGE_TOKEN ? System.getenv().CURSEFORGE_TOKEN : ""
if (apiToken.isBlank()) return

disableVersionDetection()
String module = project.name

def file = upload(curseforge_id, module == "fabric" ? remapJar : jar)
file.displayName = "v${mod_version}-${capsLoader(module)}-${minecraft_version}"
file.releaseType = release_type
file.changelog = rootProject.file("changelog.md").text
file.changelogType = 'markdown'
project.property("release_mod_loaders_${module}").split(",").each { String id ->
file.addModLoader(id)
}
project.property("release_game_versions_${module}").split(",").each { String id ->
file.addGameVersion(id, module)
}

if (project.hasProperty("release_required_dep_ids_${module}_cf")) {
project.property("release_required_dep_ids_${module}_cf").split(",").each { String id ->
file.addRequirement(id)
}
}
if (project.hasProperty("release_optional_dep_ids_${module}_cf")) {
project.property("release_optional_dep_ids_${module}_cf").split(",").each { String id ->
file.addOptional(id)
}
}
if (project.hasProperty("release_incompatible_dep_ids_${module}_cf")) {
project.property("release_incompatible_dep_ids_${module}_cf").split(",").each { String id ->
file.addIncompatibility(id)
}
}
}
tasks.curseforge.onlyIf { System.getenv().CURSEFORGE_TOKEN }
tasks.curseforge.dependsOn(build)

githubRelease {
token = System.getenv().GITHUB_TOKEN ? System.getenv().GITHUB_TOKEN : "empty"
owner = github_repo_owner
Expand Down
15 changes: 11 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,24 @@ sources_url=https://github.com/TerminalMC/AutoReconnect
issues_url=https://github.com/TerminalMC/AutoReconnect/issues
contact_url=https://terminalmc.dev

# GitHub and Modrinth releases
# GitHub, Modrinth, CurseForge releases
# Plural properties expect CSV lists
github_repo_owner=TerminalMC
github_repo=AutoReconnect
modrinth_id=PRy8Khga
curseforge_id=1049892
# 'release', 'alpha' or 'beta'
release_type=beta
# comma-separated lists
# Fabric
release_mod_loaders_fabric=fabric,quilt
release_game_versions_fabric=1.21
release_required_dep_ids_fabric=P7dR8mSH,mOgUt4GM,9s6osm5g
release_required_dep_ids_fabric_mr=P7dR8mSH,mOgUt4GM,9s6osm5g
release_required_dep_ids_fabric_cf=fabric-api,modmenu,cloth-config
# NeoForge
release_mod_loaders_neoforge=neoforge
release_game_versions_neoforge=1.21
release_required_dep_ids_neoforge=9s6osm5g
release_required_dep_ids_neoforge_mr=9s6osm5g
release_required_dep_ids_neoforge_cf=cloth-config

# Mixin https://mvnrepository.com/artifact/org.spongepowered/mixin
mixin_version=0.8.5
Expand All @@ -75,6 +80,8 @@ mixinextras_version=0.3.5
ideaext_version=1.1.8
# Minotaur https://plugins.gradle.org/plugin/com.modrinth.minotaur
minotaur_version=2.8.7
# CurseForgeGradle https://plugins.gradle.org/plugin/net.darkhax.curseforgegradle
curseforgegradle_version=1.1.24
# github-release https://plugins.gradle.org/plugin/com.github.breadmoirai.github-release
githubrelease_version=2.5.2
# grgit-service https://github.com/ajoberstar/grgit/releases
Expand Down

0 comments on commit edf7ee1

Please sign in to comment.