From 50ba07fa775c661a47887ae23f129ca2e1d62bc1 Mon Sep 17 00:00:00 2001 From: MrCrayfish <4958241+MrCrayfish@users.noreply.github.com> Date: Fri, 31 May 2024 03:50:59 +0930 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A7=20Seperate=20build=20actions=20per?= =?UTF-8?q?=20modloader?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/common.yml | 78 ++++++++++++++++++ .github/workflows/fabric.yml | 87 ++++++++++++++++++++ .github/workflows/{main.yml => forge.yml} | 24 ++---- .github/workflows/neoforge.yml | 99 +++++++++++++++++++++++ 4 files changed, 271 insertions(+), 17 deletions(-) create mode 100644 .github/workflows/common.yml create mode 100644 .github/workflows/fabric.yml rename .github/workflows/{main.yml => forge.yml} (74%) create mode 100644 .github/workflows/neoforge.yml diff --git a/.github/workflows/common.yml b/.github/workflows/common.yml new file mode 100644 index 00000000..5b079d2c --- /dev/null +++ b/.github/workflows/common.yml @@ -0,0 +1,78 @@ +name: Build and Sign Mod +on: + push: + paths: + - 'release_build_common' +jobs: + build: + runs-on: ubuntu-latest + environment: Build + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'adopt' + - name: Validate Gradle Wrapper + uses: gradle/wrapper-validation-action@v1 + - name: Read modid from gradle.properties + id: mod_id + uses: Reedyuk/read-properties@v1.0.1 + with: + path: './gradle.properties' + property: 'mod_id' + - name: Read mod version from gradle.properties + id: mod_version + uses: Reedyuk/read-properties@v1.0.1 + with: + path: './gradle.properties' + property: 'mod_version' + - name: Read minecraft version from gradle.properties + id: mc_version + uses: Reedyuk/read-properties@v1.0.1 + with: + path: './gradle.properties' + property: 'minecraft_version' + - name: Cache + uses: actions/cache@v3 + with: + path: ~/.gradle/caches + key: gradle-minecraft-${{ steps.mc_version.outputs.value }} + - name: Make gradlew executable + run: chmod +x ./gradlew + - name: Build and Publish + env: + GPR_USER: "MrCrayfish" + GPR_KEY: ${{ secrets.GPR_TOKEN }} + SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} + SIGNING_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + run: ./gradlew build + - name: Stop Gradle + run: ./gradlew --stop + - name: Construct artifact files + id: artifacts + run: | + echo "common=common/build/libs/${{ steps.mod_id.outputs.value }}-common-${{ steps.mc_version.outputs.value }}-${{ steps.mod_version.outputs.value }}.jar" >> "$GITHUB_OUTPUT" + - name: Import GPG + env: + SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} + SIGNING_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + if: ${{ env.SIGNING_KEY != '' && env.SIGNING_PASSPHRASE != '' }} + uses: crazy-max/ghaction-import-gpg@v5.3.0 + with: + gpg_private_key: ${{ env.SIGNING_KEY }} + passphrase: ${{ env.SIGNING_PASSPHRASE }} + - name: Sign JAR + env: + SIGNING_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + if: ${{ env.SIGNING_PASSPHRASE != '' }} + run: | + gpg --batch --yes --passphrase "${{ env.SIGNING_PASSPHRASE }}" --armor --detach-sign ${{ steps.artifacts.outputs.common }} + - name: Upload Common Artifacts + uses: actions/upload-artifact@v2 + with: + name: '${{ steps.mod_id.outputs.value }}-common-${{ steps.mc_version.outputs.value }}-${{ steps.mod_version.outputs.value }}' + path: | + ${{ steps.artifacts.outputs.common }} + ${{ steps.artifacts.outputs.common }}.asc diff --git a/.github/workflows/fabric.yml b/.github/workflows/fabric.yml new file mode 100644 index 00000000..4b3452ae --- /dev/null +++ b/.github/workflows/fabric.yml @@ -0,0 +1,87 @@ +name: Build and Sign Mod +on: + push: + paths: + - 'release_build_fabric' +jobs: + build: + runs-on: ubuntu-latest + environment: Build + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'adopt' + - name: Validate Gradle Wrapper + uses: gradle/wrapper-validation-action@v1 + - name: Read modid from gradle.properties + id: mod_id + uses: Reedyuk/read-properties@v1.0.1 + with: + path: './gradle.properties' + property: 'mod_id' + - name: Read mod version from gradle.properties + id: mod_version + uses: Reedyuk/read-properties@v1.0.1 + with: + path: './gradle.properties' + property: 'mod_version' + - name: Read minecraft version from gradle.properties + id: mc_version + uses: Reedyuk/read-properties@v1.0.1 + with: + path: './gradle.properties' + property: 'minecraft_version' + - name: Cache + uses: actions/cache@v3 + with: + path: ~/.gradle/caches + key: gradle-minecraft-${{ steps.mc_version.outputs.value }} + - name: Make gradlew executable + run: chmod +x ./gradlew + - name: Run Data Generation + env: + GPR_USER: "MrCrayfish" + GPR_KEY: ${{ secrets.GPR_TOKEN }} + SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} + SIGNING_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + TARGET_LOADER: "fabric" + run: ./gradlew :fabric:runDatagen + - name: Build and Publish + env: + GPR_USER: "MrCrayfish" + GPR_KEY: ${{ secrets.GPR_TOKEN }} + SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} + SIGNING_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + TARGET_LOADER: "fabric" + run: ./gradlew build + - name: Stop Gradle + run: ./gradlew --stop + - name: Construct artifact files + id: artifacts + run: | + echo "fabric=fabric/build/libs/${{ steps.mod_id.outputs.value }}-fabric-${{ steps.mc_version.outputs.value }}-${{ steps.mod_version.outputs.value }}.jar" >> "$GITHUB_OUTPUT" + - name: Import GPG + env: + SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} + SIGNING_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + if: ${{ env.SIGNING_KEY != '' && env.SIGNING_PASSPHRASE != '' }} + uses: crazy-max/ghaction-import-gpg@v5.3.0 + with: + gpg_private_key: ${{ env.SIGNING_KEY }} + passphrase: ${{ env.SIGNING_PASSPHRASE }} + - name: Sign JAR + env: + SIGNING_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + if: ${{ env.SIGNING_PASSPHRASE != '' }} + run: | + gpg --batch --yes --passphrase "${{ env.SIGNING_PASSPHRASE }}" --armor --detach-sign ${{ steps.artifacts.outputs.fabric }} + - name: Upload Fabric Artifacts + uses: actions/upload-artifact@v2 + with: + name: '${{ steps.mod_id.outputs.value }}-fabric-${{ steps.mc_version.outputs.value }}-${{ steps.mod_version.outputs.value }}' + path: | + ${{ steps.artifacts.outputs.fabric }} + ${{ steps.artifacts.outputs.fabric }}.asc diff --git a/.github/workflows/main.yml b/.github/workflows/forge.yml similarity index 74% rename from .github/workflows/main.yml rename to .github/workflows/forge.yml index 4e7039ba..71547db7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/forge.yml @@ -2,7 +2,7 @@ name: Build and Sign Mod on: push: paths: - - 'release_build' + - 'release_build_forge' jobs: build: runs-on: ubuntu-latest @@ -48,12 +48,6 @@ jobs: with: fileName: 'keystore.jks' encodedString: ${{ env.JKS }} - - name: Set Keystore Variables - if: ${{ steps.load_keystore.outputs.filePath != '' }} - run: | - echo "KEYSTORE=${{ steps.load_keystore.outputs.filePath }}" >> $GITHUB_ENV - echo "KEYSTORE_ALIAS=${{ secrets.MRCRAYFISH_JKS_ALIAS }}" >> $GITHUB_ENV - echo "KEYSTORE_PASS=${{ secrets.MRCRAYFISH_JKS_PASSPHRASE }}" >> $GITHUB_ENV - name: Make gradlew executable run: chmod +x ./gradlew - name: Run Data Generation @@ -62,13 +56,18 @@ jobs: GPR_KEY: ${{ secrets.GPR_TOKEN }} SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} SIGNING_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} - run: ./gradlew :forge:Data :fabric:runDatagen :neoforge:runData + TARGET_LOADER: "forge" + run: ./gradlew :forge:Data - name: Build and Publish env: GPR_USER: "MrCrayfish" GPR_KEY: ${{ secrets.GPR_TOKEN }} SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} SIGNING_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + KEYSTORE: ${{ steps.load_keystore.outputs.filePath }} + KEYSTORE_ALIAS: ${{ secrets.MRCRAYFISH_JKS_ALIAS }} + KEYSTORE_PASS: ${{ secrets.MRCRAYFISH_JKS_PASSPHRASE }} + TARGET_LOADER: "forge" run: ./gradlew build - name: Stop Gradle run: ./gradlew --stop @@ -76,7 +75,6 @@ jobs: id: artifacts run: | echo "forge=forge/build/libs/${{ steps.mod_id.outputs.value }}-forge-${{ steps.mc_version.outputs.value }}-${{ steps.mod_version.outputs.value }}.jar" >> "$GITHUB_OUTPUT" - echo "fabric=fabric/build/libs/${{ steps.mod_id.outputs.value }}-fabric-${{ steps.mc_version.outputs.value }}-${{ steps.mod_version.outputs.value }}.jar" >> "$GITHUB_OUTPUT" - name: Import GPG env: SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} @@ -92,7 +90,6 @@ jobs: if: ${{ env.SIGNING_PASSPHRASE != '' }} run: | gpg --batch --yes --passphrase "${{ env.SIGNING_PASSPHRASE }}" --armor --detach-sign ${{ steps.artifacts.outputs.forge }} - gpg --batch --yes --passphrase "${{ env.SIGNING_PASSPHRASE }}" --armor --detach-sign ${{ steps.artifacts.outputs.fabric }} - name: Upload Forge Artifacts uses: actions/upload-artifact@v2 with: @@ -100,10 +97,3 @@ jobs: path: | ${{ steps.artifacts.outputs.forge }} ${{ steps.artifacts.outputs.forge }}.asc - - name: Upload Fabric Artifacts - uses: actions/upload-artifact@v2 - with: - name: '${{ steps.mod_id.outputs.value }}-fabric-${{ steps.mc_version.outputs.value }}-${{ steps.mod_version.outputs.value }}' - path: | - ${{ steps.artifacts.outputs.fabric }} - ${{ steps.artifacts.outputs.fabric }}.asc diff --git a/.github/workflows/neoforge.yml b/.github/workflows/neoforge.yml new file mode 100644 index 00000000..fb29c165 --- /dev/null +++ b/.github/workflows/neoforge.yml @@ -0,0 +1,99 @@ +name: Build and Sign Mod +on: + push: + paths: + - 'release_build_neoforge' +jobs: + build: + runs-on: ubuntu-latest + environment: Build + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'adopt' + - name: Validate Gradle Wrapper + uses: gradle/wrapper-validation-action@v1 + - name: Read modid from gradle.properties + id: mod_id + uses: Reedyuk/read-properties@v1.0.1 + with: + path: './gradle.properties' + property: 'mod_id' + - name: Read mod version from gradle.properties + id: mod_version + uses: Reedyuk/read-properties@v1.0.1 + with: + path: './gradle.properties' + property: 'mod_version' + - name: Read minecraft version from gradle.properties + id: mc_version + uses: Reedyuk/read-properties@v1.0.1 + with: + path: './gradle.properties' + property: 'minecraft_version' + - name: Cache + uses: actions/cache@v3 + with: + path: ~/.gradle/caches + key: gradle-minecraft-${{ steps.mc_version.outputs.value }} + - name: Load Keystore + id: load_keystore + env: + JKS: ${{ secrets.MRCRAYFISH_JKS }} + if: ${{ env.JKS != '' }} + uses: timheuer/base64-to-file@v1.2 + with: + fileName: 'keystore.jks' + encodedString: ${{ env.JKS }} + - name: Make gradlew executable + run: chmod +x ./gradlew + - name: Run Data Generation + env: + GPR_USER: "MrCrayfish" + GPR_KEY: ${{ secrets.GPR_TOKEN }} + SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} + SIGNING_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + TARGET_LOADER: "neoforge" + run: ./gradlew :neoforge:runData + - name: Build and Publish + env: + GPR_USER: "MrCrayfish" + GPR_KEY: ${{ secrets.GPR_TOKEN }} + SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} + SIGNING_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + KEYSTORE: ${{ steps.load_keystore.outputs.filePath }} + KEYSTORE_ALIAS: ${{ secrets.MRCRAYFISH_JKS_ALIAS }} + KEYSTORE_PASS: ${{ secrets.MRCRAYFISH_JKS_PASSPHRASE }} + TARGET_LOADER: "neoforge" + run: ./gradlew build + - name: Stop Gradle + run: ./gradlew --stop + - name: Construct artifact files + id: artifacts + run: | + echo "neoforge=neoforge/build/libs/${{ steps.mod_id.outputs.value }}-neoforge-${{ steps.mc_version.outputs.value }}-${{ steps.mod_version.outputs.value }}.jar" >> "$GITHUB_OUTPUT" + - name: Import GPG + env: + SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} + SIGNING_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + if: ${{ env.SIGNING_KEY != '' && env.SIGNING_PASSPHRASE != '' }} + uses: crazy-max/ghaction-import-gpg@v5.3.0 + with: + gpg_private_key: ${{ env.SIGNING_KEY }} + passphrase: ${{ env.SIGNING_PASSPHRASE }} + - name: Sign JAR + env: + SIGNING_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + if: ${{ env.SIGNING_PASSPHRASE != '' }} + run: | + gpg --batch --yes --passphrase "${{ env.SIGNING_PASSPHRASE }}" --armor --detach-sign ${{ steps.artifacts.outputs.neoforge }} + - name: Upload Forge Artifacts + uses: actions/upload-artifact@v2 + with: + name: '${{ steps.mod_id.outputs.value }}-neoforge-${{ steps.mc_version.outputs.value }}-${{ steps.mod_version.outputs.value }}' + path: | + ${{ steps.artifacts.outputs.neoforge }} + ${{ steps.artifacts.outputs.neoforge }}.asc