chore(deps): Update gradle and github actions #316
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: "build" | |
| on: | |
| push: | |
| branches: "**" | |
| tags-ignore: ["**"] | |
| pull_request: | |
| release: | |
| types: [ released ] | |
| concurrency: | |
| group: "${{ github.workflow }}-${{ github.event.number || github.ref }}" | |
| cancel-in-progress: true | |
| jobs: | |
| build: | |
| # Only run on PRs if the source branch is on someone else's repo | |
| if: "${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }}" | |
| strategy: | |
| matrix: | |
| os: ["ubuntu-latest"] # disable windows cuz it fails ONLY in GH actions and not locally | |
| # os: ["ubuntu-latest", "windows-latest"] | |
| runs-on: "${{ matrix.os }}" | |
| steps: | |
| - name: "setup env" | |
| id: "setup" | |
| uses: "KyoriPowered/ci-cookbook/actions/setup-java-env@38f84f74c37a4f4aca1008522b32c5e9c625e10d" # 2026.03.17 | |
| with: | |
| runtime_version: 25 | |
| publishing_branch_regex: '(?:(?:(?:mc\/)?(\d+(?:\.\d+)*(?:\.x)?)))' | |
| gradle_warning_mode: "all" | |
| - name: "prime gradle build" | |
| run: "./gradlew --no-daemon generateTemplates generateTestmodTemplates --stacktrace" # Bonk loom | |
| - name: "run gradle build" | |
| run: "./gradlew build --stacktrace" | |
| - name: "archive test results" | |
| if: "${{ always() }}" | |
| uses: "actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a" # v7.0.1 | |
| with: | |
| name: "${{ runner.os }}-test-results" | |
| path: | | |
| build/reports/ | |
| */build/reports/ | |
| - name: "determine status" | |
| shell: "bash" | |
| run: | | |
| VERSION="$(./gradlew properties | awk '/^version:/ { print $2; }')" | |
| if [ "$(echo $VERSION | grep '\-SNAPSHOT')" ]; then | |
| echo "STATUS=snapshot" >> $GITHUB_ENV | |
| else | |
| echo "STATUS=release" >> $GITHUB_ENV | |
| fi | |
| echo "VERSION=$VERSION" >> $GITHUB_ENV | |
| - name: "Cache test run data" | |
| uses: "actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae" # v5.0.5 | |
| with: | |
| path: | | |
| testserver/libraries | |
| testserver/versions | |
| testserver/.fabric/server | |
| testserver/world | |
| key: testserver-${{ runner.os }}-${{ github.run_id }} | |
| restore-keys: testserver-${{ runner.os }}- | |
| - name: "Execute production test run" | |
| shell: bash | |
| run: | | |
| echo "::group::Environment Setup" | |
| pip install yq | |
| mkdir -p testserver/mods | |
| MC_VERSION="$(tomlq -r '.versions.minecraft' gradle/libs.versions.toml)" | |
| LOADER_VERSION="$(tomlq -r '.versions.fabricLoader' gradle/libs.versions.toml)" | |
| API_VERSION="$(tomlq -r '.versions.fabricApi' gradle/libs.versions.toml)" | |
| # Download fabric server launch | |
| curl https://meta.fabricmc.net/v2/versions/loader/$MC_VERSION/$LOADER_VERSION/0.11.0/server/jar -o testserver/fabric-server.jar | |
| # eula=true | |
| echo "eula=true" > testserver/eula.txt | |
| # copy artifact into mods folder | |
| cp fabric/build/libs/adventure-platform-fabric-$VERSION.jar testserver/mods/adventure-platform-fabric.jar | |
| # copy API | |
| API_URL=$(curl https://api.modrinth.com/v2/project/fabric-api/version | jq ". | map(select(.version_number == \"$API_VERSION\")) | .[0].files[0].url" -r) | |
| echo "Downloading Fabric API from $API_URL" | |
| curl -L "$API_URL" -o testserver/mods/fabric-api.jar | |
| echo "::endgroup::" # Environment Setup | |
| echo "::group::Server Execution" | |
| pushd testserver/ | |
| java -Dadventure.testMode=true -jar fabric-server.jar nogui | |
| if [[ -d "crash-reports" ]]; then | |
| for i in crash-reports/*.txt; do | |
| echo "::error title=Server crashed::$(cat $i)" | |
| done | |
| fi | |
| popd | |
| echo "::endgroup" # Server Execution | |
| echo "# Server Execution" >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| cat testserver/logs/latest.log >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| if [ ! -e "testserver/adventure-test-success.out" ]; then | |
| echo "::error::Server did not exit successfully, see logs for details" | |
| exit 1 | |
| fi | |
| - name: "publish snapshot" | |
| if: "${{ runner.os == 'Linux' && env.STATUS != 'release' && github.event_name == 'push' && steps.setup.outputs.publishing_branch != '' }}" | |
| run: "./gradlew publish" | |
| env: | |
| ORG_GRADLE_PROJECT_sonatypeUsername: "${{ secrets.ADVENTURE_SONATYPE_USERNAME }}" | |
| ORG_GRADLE_PROJECT_sonatypePassword: "${{ secrets.ADVENTURE_SONATYPE_PASSWORD }}" | |
| - name: "publish release" | |
| if: "${{ runner.os == 'Linux' && env.STATUS == 'release' && github.event_name == 'release' }}" | |
| run: "./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository" | |
| env: | |
| ORG_GRADLE_PROJECT_sonatypeUsername: "${{ secrets.ADVENTURE_SONATYPE_USERNAME }}" | |
| ORG_GRADLE_PROJECT_sonatypePassword: "${{ secrets.ADVENTURE_SONATYPE_PASSWORD }}" | |
| ORG_GRADLE_PROJECT_kyoriSigningKey: "${{ secrets.ADVENTURE_GPG_KEY }}" | |
| ORG_GRADLE_PROJECT_kyoriSigningPassword: "${{ secrets.ADVENTURE_GPG_PASSWORD }}" | |
| - name: "publish release to modrinth" | |
| if: "${{ runner.os == 'Linux' && env.STATUS == 'release' && github.event_name == 'release' }}" | |
| run: ./gradlew publishModrinth | |
| env: | |
| MODRINTH_TOKEN: "${{ secrets.PAPERMC_MODRINTH_TOKEN }}" | |
| RELEASE_NOTES: "${{ github.event.release.body }}" | |
| - name: "copy javadoc for publication" | |
| if: "${{ runner.os == 'Linux' && env.STATUS == 'release' && github.event_name == 'release' }}" | |
| run: | | |
| mkdir -p build/publish-jd/platform/ | |
| ./gradlew copyJavadoc --output build/publish-jd/platform/ | |
| - name: "authenticate for javadoc publication" | |
| if: "${{ runner.os == 'Linux' && env.STATUS == 'release' && github.event_name == 'release' }}" | |
| uses: "actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3" # v3.1.1 | |
| id: jd-token | |
| with: | |
| app-id: "${{ secrets.DEPLOYMENT_APP_ID }}" | |
| private-key: "${{ secrets.DEPLOYMENT_APP_SECRET }}" | |
| owner: "PaperMC" | |
| repositories: "adventure-javadocs" | |
| - name: "get JD app ID" | |
| if: "${{ runner.os == 'Linux' && env.STATUS == 'release' && github.event_name == 'release' }}" | |
| id: "get-app-id" | |
| run: 'echo "user-id=$(gh api "/users/${{ steps.jd-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"' | |
| - name: "publish javadoc" | |
| if: "${{ runner.os == 'Linux' && env.STATUS == 'release' && github.event_name == 'release' }}" | |
| uses: JamesIves/github-pages-deploy-action@d92aa235d04922e8f08b40ce78cc5442fcfbfa2f # v4.8.0 | |
| with: | |
| folder: build/publish-jd | |
| repository-name: "PaperMC/adventure-javadocs" | |
| token: ${{ steps.jd-token.outputs.token }} | |
| branch: main | |
| git-config-name: "${{ steps.jd-token.outputs.app-slug }}[bot]" | |
| git-config-email: "${{ steps.get-app-id.outputs.user-id }}+${{ steps.jd-token.outputs.app-slug }}[bot]@users.noreply.github.com" | |
| clean: false | |
| force: false | |
| commit-message: "Publishing javadoc for ${{ github.repository }} ${{ env.PROJECT_VERSION }}" |