From 4020c9b6674c7b47ed2b03452d9d9fb86941bfa2 Mon Sep 17 00:00:00 2001 From: NotRyken Date: Wed, 26 Jun 2024 11:24:12 +0800 Subject: [PATCH] Add CF publishing --- .github/workflows/release.yml | 3 +- build.gradle | 59 ++++++++++++++++++++++++++++------- gradle.properties | 12 +++++-- 3 files changed, 59 insertions(+), 15 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2c5ec22..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 neoforge:modrinth fabric:githubRelease fabric:modrinth --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 1e45fab..0abc042 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}") } @@ -131,19 +130,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 @@ -153,6 +152,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 ae82844..763c4ed 100644 --- a/gradle.properties +++ b/gradle.properties @@ -46,16 +46,20 @@ sources_url=https://github.com/TerminalMC/EffectTimerPlus issues_url=https://github.com/TerminalMC/EffectTimerPlus/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=EffectTimerPlus modrinth_id=JIUF2Wb5 +curseforge_id=1049882 # 'release', 'alpha' or 'beta' release_type=release -# comma-separated lists +# Fabric release_mod_loaders_fabric=fabric,quilt release_game_versions_fabric=1.21 -release_required_dep_ids_fabric=mOgUt4GM +release_required_dep_ids_fabric_mr=mOgUt4GM +release_required_dep_ids_fabric_cf=modmenu +# NeoForge release_mod_loaders_neoforge=neoforge release_game_versions_neoforge=1.21 @@ -69,6 +73,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