diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0e8b358..cdd0e6b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,5 +1,6 @@ name: CI for Mod on: + workflow_dispatch: push: branches: - releases/** @@ -13,9 +14,6 @@ on: - settings.gradle jobs: - gametest: - secrets: inherit - uses: ./.github/workflows/gametest.yml build: runs-on: ubuntu-latest env: @@ -73,3 +71,15 @@ jobs: MAVEN_USERNAME: ${{ secrets.MAVEN_USER }} MAVEN_PASSWORD: ${{ secrets.MAVEN_PASS }} continue-on-error: true + + - name: Fabric Game Test + uses: Anvil-Dev/dedicated-server-launch-test@1.20.1-fabric + with: + mod: fabric/build/libs/${{ steps.properties.outputs.mod_id }}-fabric-${{ steps.version.outputs.version }}.jar + extra-mods: fabric-api:0.92.2+1.20.1 patchouli:1.20.1-84-fabric cloth-config:11.1.136+fabric + + - name: Forge Game Test + uses: Anvil-Dev/dedicated-server-launch-test@1.20.1-forge + with: + mod: forge/build/libs/${{ steps.properties.outputs.mod_id }}-forge-${{ steps.version.outputs.version }}.jar + extra-mods: patchouli:1.20.1-84-forge cloth-config:11.1.136+forge diff --git a/.github/workflows/dev-ci.yml b/.github/workflows/dev-ci.yml deleted file mode 100644 index 0983ad8..0000000 --- a/.github/workflows/dev-ci.yml +++ /dev/null @@ -1,67 +0,0 @@ -name: CI for Mod -on: - push: - branches: - - dev/** - paths: - - src/** - - build.gradle - - gradle.properties - - settings.gradle - -jobs: - build: - runs-on: ubuntu-latest - env: - CI_BUILD: true - PR_BUILD: false - steps: - - name: checkout - uses: actions/checkout@v4 - - - name: validate gradle wrapper - uses: gradle/actions/wrapper-validation@v3 - - - name: Read Properties - id: 'properties' - uses: christian-draeger/read-properties@1.1.1 - with: - path: gradle.properties - properties: 'mod_id mod_name java_version' - - - name: Setup Java ${{ steps.properties.outputs.java_version }} - uses: actions/setup-java@v3.6.0 - with: - distribution: zulu - java-version: ${{ steps.properties.outputs.java_version }} - - - name: make gradle wrapper executable - if: ${{ runner.os != 'Windows' }} - run: chmod +x ./gradlew - - - name: Build with Gradle - uses: gradle/actions/setup-gradle@v3 - - - name: Build - run: ./gradlew build - - - name: Find correct JAR - id: find-jar - run: | - output="$(find build/libs/ ! -name "*-dev.jar" ! -name "*-sources.jar" -type f -printf "%f\n")" - echo "jarname=$output" >> $GITHUB_OUTPUT - - - name: capture build artifacts - if: ${{ runner.os == 'Linux' && matrix.java == '17' }} - uses: actions/upload-artifact@v3.1.1 - with: - name: ${{ steps.find-jar.outputs.jarname }} - path: build/libs/${{ steps.find-jar.outputs.jarname }} - - - name: Publish to maven - run: ./gradlew publish - env: - MAVEN_URL: ${{ secrets.MAVEN_URL }} - MAVEN_USERNAME: ${{ secrets.MAVEN_USER }} - MAVEN_PASSWORD: ${{ secrets.MAVEN_PASS }} - continue-on-error: true diff --git a/.github/workflows/gametest.yml b/.github/workflows/gametest.yml deleted file mode 100644 index b49a3ae..0000000 --- a/.github/workflows/gametest.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: Pull Request GameTest -on: workflow_call - -jobs: - test: - runs-on: ubuntu-latest - steps: - - name: checkout - uses: actions/checkout@v4 - - - name: validate gradle wrapper - uses: gradle/actions/wrapper-validation@v3 - - - name: Read Properties - id: 'properties' - uses: christian-draeger/read-properties@1.1.1 - with: - path: gradle.properties - properties: 'mod_id java_version' - - - name: Setup Java ${{ steps.properties.outputs.java_version }} - uses: actions/setup-java@v3.6.0 - with: - distribution: zulu - java-version: ${{ steps.properties.outputs.java_version }} - - - name: make gradle wrapper executable - if: ${{ runner.os != 'Windows' }} - run: chmod +x ./gradlew - - - name: Build with Gradle - uses: gradle/actions/setup-gradle@v3 - - - name: Run Fabric GameTest - run: ./gradlew ${{ steps.properties.outputs.mod_id }}-fabric:runGameTestServer - - - name: Run Forge GameTest - run: ./gradlew ${{ steps.properties.outputs.mod_id }}-forge:runGameTestServer - - - name: Run NeoForge GameTest - run: ./gradlew ${{ steps.properties.outputs.mod_id }}-neoforge:runGameTestServer diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 994ce15..b96130a 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -1,19 +1,19 @@ name: Pull Request Check on: + workflow_dispatch: pull_request: + branches: + - releases/** paths: + - src/** - common/** - fabric/** - forge/** - - neoforge/** - build.gradle - gradle.properties - settings.gradle jobs: - gametest: - secrets: inherit - uses: ./.github/workflows/gametest.yml build: runs-on: ubuntu-latest env: @@ -63,3 +63,15 @@ jobs: fabric/build/libs/${{ steps.properties.outputs.mod_id }}-fabric-${{ steps.version.outputs.version }}.jar forge/build/libs/${{ steps.properties.outputs.mod_id }}-forge-${{ steps.version.outputs.version }}.jar neoforge/build/libs/${{ steps.properties.outputs.mod_id }}-neoforge-${{ steps.version.outputs.version }}.jar + + - name: Fabric Game Test + uses: Anvil-Dev/dedicated-server-launch-test@1.20.1-fabric + with: + mod: fabric/build/libs/${{ steps.properties.outputs.mod_id }}-fabric-${{ steps.version.outputs.version }}.jar + extra-mods: fabric-api:0.92.2+1.20.1 patchouli:1.20.1-84-fabric cloth-config:11.1.136+fabric + + - name: Forge Game Test + uses: Anvil-Dev/dedicated-server-launch-test@1.20.1-forge + with: + mod: forge/build/libs/${{ steps.properties.outputs.mod_id }}-forge-${{ steps.version.outputs.version }}.jar + extra-mods: patchouli:1.20.1-84-forge cloth-config:11.1.136+forge diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6071f14..2b92b73 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,16 +1,17 @@ name: Upload Release Asset on: + workflow_dispatch: release: types: [ published ] jobs: build: permissions: write-all + runs-on: ubuntu-latest env: CI_BUILD: false PR_BUILD: false VERSION_TYPE: ${{ github.event.release.prerelease && 'alpha' || 'release' }} - runs-on: ubuntu-latest steps: - name: checkout uses: actions/checkout@v4 @@ -56,6 +57,14 @@ jobs: forge/build/libs/${{ steps.properties.outputs.mod_id }}-forge-${{ steps.version.outputs.version }}.jar neoforge/build/libs/${{ steps.properties.outputs.mod_id }}-neoforge-${{ steps.version.outputs.version }}.jar + - name: Publish to maven + run: ./gradlew publish + env: + MAVEN_URL: ${{ secrets.MAVEN_URL }} + MAVEN_USERNAME: ${{ secrets.MAVEN_USER }} + MAVEN_PASSWORD: ${{ secrets.MAVEN_PASS }} + continue-on-error: true + - name: Upload Release Jar uses: softprops/action-gh-release@v0.1.15 with: @@ -64,14 +73,6 @@ jobs: forge/build/libs/${{ steps.properties.outputs.mod_id }}-forge-${{ steps.version.outputs.version }}.jar neoforge/build/libs/${{ steps.properties.outputs.mod_id }}-neoforge-${{ steps.version.outputs.version }}.jar - - name: Publish to maven - run: ./gradlew publish - env: - MAVEN_URL: ${{ secrets.MAVEN_URL }} - MAVEN_USERNAME: ${{ secrets.MAVEN_USER }} - MAVEN_PASSWORD: ${{ secrets.MAVEN_PASS }} - continue-on-error: true -# # - name: publish forge mc mod # uses: Kir-Antipov/mc-publish@v3.3 # continue-on-error: true @@ -84,11 +85,11 @@ jobs: # fail-mode: skip # changelog: ${{ github.event.release.body }} # -# modrinth-id: "****" +# modrinth-id: ${{ steps.properties.outputs.modrinth_id }} # modrinth-token: ${{ secrets.MODRINTH_TOKEN }} # modrinth-featured: true # -# curseforge-id: "****" +# curseforge-id: ${{ steps.properties.outputs.curseforge_id }} # curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }} # # files: | @@ -108,11 +109,11 @@ jobs: # fail-mode: skip # changelog: ${{ github.event.release.body }} # -# modrinth-id: "****" +# modrinth-id: ${{ steps.properties.outputs.modrinth_id }} # modrinth-token: ${{ secrets.MODRINTH_TOKEN }} # modrinth-featured: true # -# curseforge-id: "****" +# curseforge-id: ${{ steps.properties.outputs.curseforge_id }} # curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }} # # files: | diff --git a/common/src/main/java/dev/anvilcraft/lib/AnvilLib.java b/common/src/main/java/dev/anvilcraft/lib/AnvilLib.java index 46f8044..5c45710 100644 --- a/common/src/main/java/dev/anvilcraft/lib/AnvilLib.java +++ b/common/src/main/java/dev/anvilcraft/lib/AnvilLib.java @@ -3,6 +3,9 @@ import dev.anvilcraft.lib.util.Platform; import dev.architectury.injectables.annotations.ExpectPlatform; +import net.minecraft.resources.ResourceLocation; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -15,6 +18,16 @@ public static void init() { } + public static @NotNull ResourceLocation of(@NotNull String path) { + String namespace = MOD_ID; + if (path.contains(":")) { + namespace = path.split(":")[0]; + path = path.split(":")[1]; + } + return new ResourceLocation(namespace, path); + } + + @SuppressWarnings("unused") @ExpectPlatform public static Platform getPlatform() { throw new AssertionError();