Add an option to WorldCreator to avoid spawn location computation on world creation #23257
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
| # Here lie dragons! | |
| # | |
| # This action either builds the server or | |
| # builds a paperclip jar to be updated in the body | |
| # of the PR relating to this action. | |
| name: Build Paper | |
| on: | |
| push: | |
| pull_request: | |
| types: | |
| - opened | |
| - reopened | |
| - synchronize | |
| - labeled | |
| jobs: | |
| build: | |
| env: | |
| ORG_GRADLE_PROJECT_paperBuildCacheEnabled: true | |
| ORG_GRADLE_PROJECT_paperBuildCacheUsername: ${{ secrets.PAPER_BUILD_CACHE_USERNAME }} | |
| ORG_GRADLE_PROJECT_paperBuildCachePassword: ${{ secrets.PAPER_BUILD_CACHE_PASSWORD }} | |
| ORG_GRADLE_PROJECT_paperBuildCachePush: true | |
| # The goal of the build workflow is split into multiple requirements. | |
| # 1. Run on pushes to same repo. | |
| # 2. Run on PR open/reopen/syncs from repos that are not the same (PRs from the same repo are covered by 1) | |
| # 3. Run on labeled PRs that have the publish-pr flag. | |
| if: > | |
| ( | |
| (github.event_name == 'push') | |
| || (github.event_name == 'pull_request' && github.repository != github.event.pull_request.head.repo.full_name && contains(fromJSON('["opened", "reopened", "synchronize"]'), github.event.action)) | |
| || (github.event_name == 'pull_request' && github.event.action == 'labeled' && github.event.label.name == 'publish-pr') | |
| ) | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: true | |
| steps: | |
| - if: ${{ github.event_name == 'push' }} | |
| uses: actions/checkout@v4 | |
| with: | |
| # todo remove me again after the update | |
| ref: ${{ github.ref_name }} | |
| fetch-depth: 0 | |
| - if: ${{ github.event_name == 'pull_request' }} | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| - name: JDK 21 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: 21 | |
| distribution: 'zulu' | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v4 | |
| with: | |
| # Allow cache writes on main and dev branches | |
| cache-read-only: ${{ github.ref != 'refs/heads/main' && !startsWith(github.ref, 'refs/heads/dev/') }} | |
| - name: Configure Build | |
| uses: actions/github-script@v7 | |
| id: determine | |
| env: | |
| REF_NAME: "${{ github.ref_name }}" | |
| REF_TYPE: "${{ github.ref_type }}" | |
| EVENT: "${{ toJSON(github.event) }}" | |
| EVENT_TYPE: "${{ github.event_name }}" | |
| with: | |
| script: | | |
| const {owner, repo} = context.repo; | |
| const event_name = `${process.env.EVENT_TYPE}`; | |
| const event = JSON.parse(`${process.env.EVENT}`); | |
| const ref_type = `${process.env.REF_TYPE}`; | |
| const ref_name = `${process.env.REF_NAME}`; | |
| const result = { | |
| action: "build" | |
| }; | |
| if (event_name === "push" && ref_type === "branch") { | |
| const {data: pulls} = await github.rest.pulls.list({ owner, repo, head: `${owner}:${ref_name}`, state: "open" }); | |
| const pull = pulls.find((pr) => !!pr.labels.find((l) => l.name === "publish-pr")); | |
| if (pull) { | |
| result["pr"] = pull.number; | |
| result["action"] = "paperclip"; | |
| core.notice(`This is a push action but to a branch with an open PR with the build paperclip label (${JSON.stringify(result)})`); | |
| return result; | |
| } | |
| } else if (event_name === "pull_request" && event.pull_request.labels.find((l) => l.name === "publish-pr")) { | |
| result["pr"] = event.pull_request.number; | |
| result["action"] = "paperclip"; | |
| core.notice(`This is a pull request action with a build paperclip label (${JSON.stringify(result)})`); | |
| return result; | |
| } | |
| core.notice("This will not build a paperclip jar"); | |
| return result; | |
| - name: Apply Patches | |
| run: | | |
| git config --global user.email "[email protected]" | |
| git config --global user.name "GitHub Actions" | |
| ./gradlew applyPatches --stacktrace | |
| - name: Build | |
| run: ./gradlew build --stacktrace | |
| - name: Upload Test Results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: Test Results | |
| path: | | |
| **/build/test-results/test/TEST-*.xml | |
| - name: Create Paperclip Jar | |
| if: fromJSON(steps.determine.outputs.result).action == 'paperclip' | |
| run: ./gradlew createMojmapPaperclipJar --stacktrace | |
| - name: Upload Paperclip Jar | |
| if: fromJSON(steps.determine.outputs.result).action == 'paperclip' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: paper-${{ fromJSON(steps.determine.outputs.result).pr }} | |
| path: paper-server/build/libs/paper-paperclip-*-mojmap.jar | |
| - name: Publish Artifacts | |
| if: fromJSON(steps.determine.outputs.result).action == 'paperclip' | |
| uses: PaperMC/action-pr-publishing/upload@paper | |
| with: | |
| # TODO fallback for failing javadoc | |
| publishing-task: ":paper-api:publishAllPublicationsTo_githubPackages_PRsRepository publishDevBundlePublicationTo_githubPackages_PRsRepository -PpublishDevBundle" | |
| event_file: | |
| name: "Event File" | |
| # 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 }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Upload | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: Event File | |
| path: ${{ github.event_path }} |