From e4b4cc14127dcd25bbfd098d39d5c45cda70a18f Mon Sep 17 00:00:00 2001 From: pedroksl Date: Mon, 23 Dec 2024 21:31:33 -0300 Subject: [PATCH] Added mod publisher to gradle setup --- .github/actions/gradle-setup/action.yml | 24 ----- .github/workflows/release.yml | 115 ------------------------ build.gradle | 96 ++++++++++++++++++-- settings.gradle | 3 + 4 files changed, 91 insertions(+), 147 deletions(-) delete mode 100644 .github/actions/gradle-setup/action.yml delete mode 100644 .github/workflows/release.yml diff --git a/.github/actions/gradle-setup/action.yml b/.github/actions/gradle-setup/action.yml deleted file mode 100644 index 82692c09..00000000 --- a/.github/actions/gradle-setup/action.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: 'Gradle Setup' -description: 'Set up the basics to run gradle' -runs: - using: "composite" - steps: - - name: Export release tag as environment variable - shell: bash - env: - TAG: ${{ github.event.release.tag_name }} - run: | - echo "TAG=${TAG}" >> $GITHUB_ENV - - - uses: gradle/actions/wrapper-validation@v3 - - - name: Set up JDK 21 - uses: actions/setup-java@v4 - with: - distribution: 'microsoft' - java-version: '21' - - - name: Setup Gradle - uses: gradle/actions/setup-gradle@v3 - with: - cache-read-only: ${{ github.ref != 'refs/heads/main' }} \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 1d8d9140..00000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,115 +0,0 @@ -name: 'Release' - -on: - release: - types: [ published ] - -jobs: - build: - name: Build - runs-on: ubuntu-latest - outputs: - ARTIFACT_PATH: ${{ steps.prepare_artifact_metadata.outputs.ARTIFACT_PATH }} - ARTIFACT_NAME: ${{ steps.prepare_artifact_metadata.outputs.ARTIFACT_NAME }} - VERSION: ${{ steps.prepare_artifact_metadata.outputs.VERSION }} - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 50 - - run: git fetch origin --tags - shell: bash - - uses: ./.github/actions/gradle-setup - - name: Build with Gradle - run: chmod +x ./gradlew printProjectVersion build publish -x check --max-workers 1 - - name: Prepare artifact metadata. Note that VERSION is set by the gradle script. - id: prepare_artifact_metadata - run: | - echo ARTIFACT_PATH=./build/libs/AdvancedAE-${VERSION}-1.21.1.jar >> $GITHUB_OUTPUT - echo ARTIFACT_NAME=AdvancedAE-${VERSION}-1.21.1.jar >> $GITHUB_OUTPUT - echo VERSION=${VERSION} >> $GITHUB_OUTPUT - - name: Archive build results - # It is important to archive .gradle as well since gradle stores the incremental build state there - run: tar -I zstd -cf build.tar.zst build/libs build/repo - - name: Upload build and gradle folders - uses: actions/upload-artifact@v4 - with: - name: build-artifacts - path: build.tar.zst - if-no-files-found: error - retention-days: 3 - - upload-release-artifacts: - name: Upload Release Artifacts - needs: build - runs-on: ubuntu-latest - steps: - - name: Download build artifact - uses: actions/download-artifact@v4 - with: - name: build-artifacts - - name: Unpack build artifact - run: tar axf build.tar.zst - - name: Upload Release Artifact - uses: actions/upload-release-asset@v1.0.1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ github.event.release.upload_url }} - asset_path: ${{ needs.build.outputs.ARTIFACT_PATH }} - asset_name: ${{ needs.build.outputs.ARTIFACT_NAME }} - asset_content_type: application/zip - - deploy-curseforge: - name: Deploy to Curseforge - needs: build - runs-on: ubuntu-latest - steps: - - name: Download build artifact - uses: actions/download-artifact@v4 - with: - name: build-artifacts - - name: Unpack build artifact - run: tar axf build.tar.zst - - name: Validate artifacts exist - run: test -d ./build - - name: Upload to Curseforge - uses: Kir-Antipov/mc-publish@995edadc13559a8b28d0b7e6571229f067ec7659 - with: - name: AAE ${{ needs.build.outputs.VERSION }} [NEOFORGE] - version: ${{ needs.build.outputs.VERSION }} - files: ${{ needs.build.outputs.ARTIFACT_PATH }} - dependencies: | - ae2(required){modrinth:XxWD5pD3}{curseforge:223794} - glodium(required){modrinth:UhW5uCKw}{curseforge:957920} - geckolib(optional){modrinth:8BmcQJ2H}{curseforge:388172} - curseforge-id: 1084104 - curseforge-token: ${{ secrets.CURSEFORGE }} - loaders: neoforge - - deploy-modrinth: - name: Deploy to Modrinth - needs: build - runs-on: ubuntu-latest - steps: - - name: Download build artifact - uses: actions/download-artifact@v4 - with: - name: build-artifacts - - name: Unpack build artifact - run: tar axf build.tar.zst - - name: Validate artifacts exist - run: test -d ./build - - name: Upload to Modrinth - uses: Kir-Antipov/mc-publish@995edadc13559a8b28d0b7e6571229f067ec7659 - with: - name: AE2 ${{ needs.build.outputs.VERSION }} [NEOFORGE] - version: ${{ needs.build.outputs.VERSION }} - files: ${{ needs.build.outputs.ARTIFACT_PATH }} - dependencies: | - ae2(required){modrinth:XxWD5pD3}{curseforge:223794} - glodium(required){modrinth:UhW5uCKw}{curseforge:957920} - geckolib(optional){modrinth:8BmcQJ2H}{curseforge:388172} - modrinth-id: rxYaglEe - modrinth-token: ${{ secrets.MODRINTH }} - loaders: neoforge diff --git a/build.gradle b/build.gradle index a0056a89..a0118f63 100644 --- a/build.gradle +++ b/build.gradle @@ -1,8 +1,11 @@ +import com.hypherionmc.modpublisher.properties.ModLoader + plugins { id 'java-library' id 'maven-publish' id 'net.neoforged.moddev' version '1.0.17' id 'com.diffplug.spotless' + id "com.hypherionmc.modutils.modpublisher" version '2.1.6' } tasks.named('wrapper', Wrapper).configure { @@ -17,7 +20,7 @@ repositories { } base { - archivesName = mod_id + archivesName = mod_name.replace(" ", "") } java.toolchain.languageVersion = JavaLanguageVersion.of(21) @@ -190,14 +193,91 @@ idea { } } -spotless { -// kotlinGradle { -// target("*.kts") -// diktat() -// indentWithTabs(1) -// endWithNewline() -// } +publisher { + apiKeys { + // Modrinth Token + modrinth System.getenv("MODRINTH_TOKEN") + // Curseforge Token + curseforge System.getenv("CURSE_TOKEN") + // GitHub Token + github System.getenv("GITHUB_TOKEN") + } + + // Enable Debug mode. When enabled, no files will actually be uploaded + setDebug(false) + + // Curseforge Project ID + setCurseID("1084104") + + // Modrinth Project ID + setModrinthID("rxYaglEe") + + // Type of release. beta, alpha or release + // You can also use VersionType.BETA, VersionType.ALPHA or VersionType.RELEASE + setVersionType("RELEASE") + + // Changelog. This can be a file, string, OR, gist/github url + // For example: markdown.md, or "This is my changelog" + // Or: https://raw.githubusercontent.com/hypherionmc/changelogs/changelog.md + // Or https://gist.githubusercontent.com/hypherionmc/92f825d3c9337964cc77c9c8c9bf65e6/raw/ceeaaee5b98c688a23398864fe480b84796a1651/test_gist.md + setChangelog("https://raw.githubusercontent.com/pedroksl/AdvancedAE/refs/heads/master/CHANGELOG.md") + + // Required for Modrinth/GitHub + setProjectVersion("${project.version}") + + // Fancy display name for the upload. + // Will default to the project version if not set + setDisplayName("AdvancedAE-${project.version}") + + // The supported game versions + setGameVersions("${project.minecraft_version}") + + // The modloaders your upload supports. + // This can also be an Enum from ModLoader, + // like setLoaders(ModLoader.FABRIC, ModLoader.FORGE) + setLoaders(ModLoader.NEOFORGE) + + // The new Curseforge Environment tag. Optional + // Valid values are "server", "client" or "both" + // You can also use CurseEnvironment.BOTH, or CurseEnvironment.SERVER or CurseEnvironment.CLIENT + setCurseEnvironment("both") + + // The file to be uploaded. This can be a file, task, or string. + // setArtifact("build/libs/mymod.jar") + // setArtifact(jar.getArchiveFile().get()) + // If this is a task, the task specified will be executed before publishing + setArtifact("build/libs/${project.mod_name.replace(" ", "")}-${project.version}.jar") + // Disable the built in Fractureizer scanner + setDisableMalwareScanner(true) + + // Safety check to check if the artifact contains a valid mod metadata entry, + // which could possibly mean that the jar is empty + setDisableEmptyJarCheck(true) + + github { + repo = "pedroksl/AdvancedAE" + + tag = "${project.version}-neoforge" + + createTag = true + createRelease = true + draft = false + updateRelease = true + + displayName = "AdvancedAE-${project.version}" + } + + curseDepends { + required "applied-energistics-2", "glodium", "geckolib" + } + + modrinthDepends { + required "ae2", "glodium", "geckolib" + } +} + +spotless { java { target("/src/**/java/**/*.java") endWithNewline() diff --git a/settings.gradle b/settings.gradle index 2607a1d2..cfb6b2c7 100644 --- a/settings.gradle +++ b/settings.gradle @@ -3,6 +3,9 @@ pluginManagement { mavenLocal() gradlePluginPortal() maven { url = 'https://maven.neoforged.net/releases' } + maven { + url "https://maven.firstdark.dev/releases" + } } plugins { id("com.diffplug.spotless") version "6.25.0"