diff --git a/.github/workflows/build_head.yml b/.github/workflows/build_head.yml index 12df3f7..04c2576 100644 --- a/.github/workflows/build_head.yml +++ b/.github/workflows/build_head.yml @@ -16,7 +16,7 @@ jobs: steps: - id: vars run: | - echo ::set-output name=VERSION::git-${GITHUB_SHA:0:7} + echo "VERSION=${GITHUB_SHA:0:7}" >> $GITHUB_OUTPUT - uses: actions/checkout@v2 - uses: actions/setup-java@v1 with: diff --git a/.github/workflows/build_release.yml b/.github/workflows/build_release.yml index 8c7e215..a66468a 100644 --- a/.github/workflows/build_release.yml +++ b/.github/workflows/build_release.yml @@ -8,7 +8,7 @@ jobs: steps: - id: vars run: | - echo ::set-output name=VERSION::${GITHUB_REF#refs/*/} + echo "VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT - uses: actions/checkout@v2 - uses: actions/setup-java@v1 with: @@ -19,10 +19,11 @@ jobs: path: ~/.gradle/caches key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle.kts') }} restore-keys: ${{ runner.os }}-gradle - - run: ./gradlew build curseforge + - run: ./gradlew build publishMods env: MOD_VERSION: ${{ steps.vars.outputs.VERSION }} CURSEFORGE_API: ${{ secrets.CURSEFORGE_API }} + MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} - uses: actions/upload-artifact@v2 with: name: build ${{ steps.vars.outputs.VERSION }} diff --git a/build.gradle.kts b/build.gradle.kts index f199502..8e57e3a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,10 +1,8 @@ -import com.matthewprenger.cursegradle.CurseArtifact -import com.matthewprenger.cursegradle.CurseProject -import com.matthewprenger.cursegradle.CurseRelation +import me.modmuss50.mpp.ReleaseType plugins { - id("fabric-loom").version("1.4.+") - id("com.matthewprenger.cursegradle").version("1.4.0") + id("fabric-loom") version "1.4.+" + id("me.modmuss50.mod-publish-plugin") version "0.4.5" } val env: Map = System.getenv() @@ -67,41 +65,33 @@ dependencies { } } -curseforge { - env["CURSEFORGE_API"]?.let { CURSEFORGE_API -> - apiKey = CURSEFORGE_API - project(closureOf { - id = prop["cf.projectId"] - releaseType = prop["cf.releaseType"] - - changelogType = "markdown" - changelog = "https://github.com/badasintended/cpas/releases/tag/${project.version}" - - mainArtifact(tasks["remapJar"], closureOf { - displayName = "[${prop["minecraft"]}] v${project.version}" - }) - - addGameVersion("Fabric") - prop["cf.gameVersion"].split(", ").forEach { - addGameVersion(it) - } - - relations(closureOf { - prop.ifPresent("cf.require") { require -> - require.split(", ").forEach { - requiredDependency(it) - } - } - prop.ifPresent("cf.optional") { optional -> - optional.split(", ").forEach { - optionalDependency(it) - } - } - }) - - afterEvaluate { - uploadTask.dependsOn("build") - } - }) +publishMods { + file.set(tasks.remapJar.get().archiveFile) + changelog.set("https://github.com/badasintended/cpas/releases/tag/${project.version}") + type.set(ReleaseType.of(prop["releaseType"])) + modLoaders.add("fabric") + + env["CURSEFORGE_API"]?.let { apiKey -> + curseforge { + accessToken.set(apiKey) + projectId.set(prop["cf.projectId"]) + + minecraftVersions.addAll(prop["cf.gameVersion"].split(", ")) + + prop.ifPresent("cf.require") { requires(*it.split(", ").toTypedArray()) } + prop.ifPresent("cf.optional") { optional(*it.split(", ").toTypedArray()) } + } + } + + env["MODRINTH_TOKEN"]?.let { token -> + modrinth { + accessToken.set(token) + projectId.set(prop["cf.projectId"]) + + minecraftVersions.addAll(prop["mr.gameVersion"].split(", ")) + + prop.ifPresent("mr.require") { requires(*it.split(", ").toTypedArray()) } + prop.ifPresent("mr.optional") { optional(*it.split(", ").toTypedArray()) } + } } } diff --git a/gradle.properties b/gradle.properties index 92f35d6..c5280ff 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,9 +13,17 @@ fabric = 0.58.0+1.19 trinkets = 3.4.0 rei = 9.1.668 +# Publishing +releaseType = stable + # CurseForge cf.projectId = 422447 -cf.releaseType = release -cf.gameVersion = 1.19 +cf.gameVersion = 1.19, 1.19.1, 1.19.2 cf.require = fabric-api cf.optional = roughly-enough-items, trinkets-fabric + +# Modrinth +mr.projectId = lJcgfZtA +mr.gameVersion = 1.19, 1.19.1, 1.19.2 +mr.require = fabric-api +mr.optional = rei, trinkets