diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2630980a3..067b09a57 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,15 +1,26 @@ name: Release -on: [workflow_dispatch] # Manual trigger +on: + workflow_dispatch: + inputs: + release_type: + description: 'The published artifact release type' + required: false + default: 'STABLE' + type: choice + options: + - STABLE + - BETA + - ALPHA permissions: contents: write jobs: build: + name: Build runs-on: ubuntu-22.04 - container: - image: mcr.microsoft.com/openjdk/jdk:21-ubuntu - options: --user root + outputs: + changelog: ${{ steps.changelog.outputs.changelog }} steps: - run: apt update && apt install git -y && git --version - run: git config --global --add safe.directory /__w/fabric/fabric @@ -21,16 +32,61 @@ jobs: with: context: changelog workflow_id: release.yml + - uses: actions/setup-java@v3 + with: + distribution: 'microsoft' + java-version: '21' - uses: gradle/wrapper-validation-action@v2 - - run: ./gradlew checkVersion build publish publishMods --stacktrace + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 + with: + gradle-home-cache-cleanup: true + - name: Build with Gradle + run: ./gradlew clean build --stacktrace + publish: + strategy: + matrix: + include: + - name: Maven + task: publish + url: https://maven.su5ed.dev/releases/org/sinytra/forgified-fabric-api + - name: GitHub + task: publishGithub + url: https://github.com/Sinytra/ForgifiedFabricAPI/releases + - name: CurseForge + task: publishCurseforge + url: https://www.curseforge.com/minecraft/mc-mods/forgified-fabric-api + - name: Modrinth + task: publishModrinth + url: https://modrinth.com/mod/forgified-fabric-api + name: Publish ${{ matrix.name }} + needs: build + runs-on: ubuntu-22.04 + environment: + name: ${{ matrix.name }} + url: ${{ matrix.url }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-java@v3 + with: + distribution: 'microsoft' + java-version: '21' + - uses: gradle/wrapper-validation-action@v1 + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 + with: + cache-read-only: true + gradle-home-cache-cleanup: true + - name: Publish with Gradle + run: ./gradlew clean build ${{ matrix.task }} --stacktrace env: + PUBLISH_RELEASE_TYPE: ${{ inputs.release_type }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }} + MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} MAVEN_URL: ${{ secrets.MAVEN_URL }} MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} - CURSEFORGE_API_KEY: ${{ secrets.CURSEFORGE_API_KEY }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} - CHANGELOG: ${{ steps.changelog.outputs.changelog }} - SIGNING_SERVER: ${{ secrets.SIGNING_SERVER }} - SIGNING_PGP_KEY: ${{ secrets.SIGNING_PGP_KEY }} - SIGNING_JAR_KEY: ${{ secrets.SIGNING_JAR_KEY }} + CHANGELOG: ${{ needs.build.outputs.changelog }} diff --git a/build.gradle.kts b/build.gradle.kts index 471f58b3f..3beb13e9f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,3 +1,4 @@ +import me.modmuss50.mpp.ReleaseType import net.fabricmc.loom.build.nesting.IncludedJarFactory import net.fabricmc.loom.build.nesting.JarNester import net.fabricmc.loom.util.Constants @@ -9,6 +10,7 @@ plugins { java `maven-publish` id("dev.architectury.loom") // Version declared in buildSrc + id("me.modmuss50.mod-publish-plugin") version "0.5.+" } val implementationVersion: String by project @@ -16,6 +18,11 @@ val versionMc: String by project val versionForge: String by project val versionForgifiedFabricLoader: String by project +val curseForgeId: String by project +val modrinthId: String by project +val githubRepository: String by project +val publishBranch: String by project + val META_PROJECTS: List = listOf( "deprecated", "fabric-api-bom", @@ -96,27 +103,6 @@ allprojects { }) } - tasks.named("jar") { - doLast { - val factory = IncludedJarFactory(project) - val nestedJars = factory.getNestedJars(configurations.getByName(Constants.Configurations.INCLUDE)) - - if (!nestedJars.isPresent) { - logger.info("No jars to nest") - return@doLast - } - - val jars: MutableSet = LinkedHashSet(nestedJars.get().files) - JarNester.nestJars( - jars, - emptyList(), - archiveFile.get().asFile, - loom.platform.get(), - project.logger - ) - } - } - // Run this task after updating minecraft to regenerate any required resources tasks.register("generateResources") { @@ -129,6 +115,23 @@ dependencies { } tasks { + named("jar") { + doLast { + val factory = IncludedJarFactory(project) + val config = configurations.getByName(Constants.Configurations.INCLUDE) + val nestedJars = factory.getNestedJars(config) + val forgeNestedJars = factory.getForgeNestedJars(config) + + JarNester.nestJars( + nestedJars.get().files, + forgeNestedJars.get().left.map { it.resolve() }, + archiveFile.get().asFile, + loom.platform.get(), + project.logger + ) + } + } + withType { options.release = 21 } @@ -177,6 +180,45 @@ allprojects { from(components["java"]) } } + repositories { + val env = System.getenv() + if (env["MAVEN_URL"] != null) { + repositories.maven { + url = uri(env["MAVEN_URL"] as String) + if (env["MAVEN_USERNAME"] != null) { + credentials { + username = env["MAVEN_USERNAME"] + password = env["MAVEN_PASSWORD"] + } + } + } + } + } + } +} + +publishMods { + file.set(tasks.jar.flatMap { it.archiveFile }) + changelog.set(providers.environmentVariable("CHANGELOG").orElse("# $version")) + type.set(providers.environmentVariable("PUBLISH_RELEASE_TYPE").orElse("alpha").map(ReleaseType::of)) + modLoaders.add("neoforge") + dryRun.set(!providers.environmentVariable("CI").isPresent) + displayName.set("[$versionMc] Forgified Fabric API $version") + + github { + accessToken.set(providers.environmentVariable("GITHUB_TOKEN")) + repository.set(githubRepository) + commitish.set(publishBranch) + } + curseforge { + accessToken.set(providers.environmentVariable("CURSEFORGE_TOKEN")) + projectId.set(curseForgeId) + minecraftVersions.add(versionMc) + } + modrinth { + accessToken.set(providers.environmentVariable("MODRINTH_TOKEN")) + projectId.set(modrinthId) + minecraftVersions.add(versionMc) } } diff --git a/buildSrc/src/main/kotlin/ffapi.neo-conversion.gradle.kts b/buildSrc/src/main/kotlin/ffapi.neo-conversion.gradle.kts index 7e399c9ed..c35a8daaa 100644 --- a/buildSrc/src/main/kotlin/ffapi.neo-conversion.gradle.kts +++ b/buildSrc/src/main/kotlin/ffapi.neo-conversion.gradle.kts @@ -44,6 +44,9 @@ extensions.getByType().configureEach { tasks.named("generate") { dependsOn(task) } + tasks.named("jar") { + exclude("fabric.mod.json") + } } afterEvaluate { diff --git a/buildSrc/src/main/kotlin/ffapi.neo-setup.gradle.kts b/buildSrc/src/main/kotlin/ffapi.neo-setup.gradle.kts index 871571915..78289e6c1 100644 --- a/buildSrc/src/main/kotlin/ffapi.neo-setup.gradle.kts +++ b/buildSrc/src/main/kotlin/ffapi.neo-setup.gradle.kts @@ -8,8 +8,6 @@ val versionFabricLoader: String by rootProject val loom = extensions.getByType() val sourceSets = extensions.getByType() -val jar = tasks.named("jar") - val mainSourceSet = sourceSets.getByName("main") mainSourceSet.apply { @@ -49,15 +47,25 @@ dependencies { "testRuntimeOnly"("org.junit.jupiter:junit-jupiter-engine:5.8.1") } -tasks.named("test") { - useJUnitPlatform() - enabled = false -} - -tasks.named("processResources") { - filesMatching("assets/*/icon.png") { - exclude() - rootProject.file("src/main/resources/assets/fabric/icon.png").copyTo(destinationDir.resolve(path)) +tasks { + named("jar") { + manifest { + attributes( + "Implementation-Version" to project.version + ) + } + } + + named("test") { + useJUnitPlatform() + enabled = false + } + + named("processResources") { + filesMatching("assets/*/icon.png") { + exclude() + rootProject.file("src/main/resources/assets/fabric/icon.png").copyTo(destinationDir.resolve(path)) + } } } diff --git a/ffapi.gradle.properties b/ffapi.gradle.properties index 67d14abd1..1cda1c863 100644 --- a/ffapi.gradle.properties +++ b/ffapi.gradle.properties @@ -7,3 +7,9 @@ versionMc=1.21 versionForge=21.0.57-beta versionForgifiedFabricLoader=2.5.24+0.15.10+1.21 versionFabricLoader=0.15.10 + +curseForgeId=889079 +modrinthId=Aqlf1Shp +githubRepository=Sinytra/Connector +# This is the branch the release tag will be created from +publishBranch=neo/1.21 \ No newline at end of file