diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index dba81cc..585420e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 diff --git a/build.gradle b/build.gradle index 180a3a0..b13dc00 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,3 @@ -import com.modrinth.minotaur.dependencies.ModDependency - plugins { id("java") id("java-library") @@ -7,6 +5,7 @@ plugins { 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}") } @@ -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 @@ -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 diff --git a/gradle.properties b/gradle.properties index 44ca036..786e5a6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 @@ -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