Update to 26.1-rc-1 #257
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
| # This is a basic workflow that is manually triggered | |
| name: Update | |
| run-name: ${{ inputs.new_version && format('Update to {0}', inputs.new_version) || (inputs.update_tools && 'Update Tools' || 'Update') }} | |
| permissions: | |
| contents: write | |
| actions: write # Needed to trigger publish workflow | |
| # Controls when the action will run. Workflow runs when manually triggered using the UI | |
| # or API. | |
| on: | |
| workflow_call: | |
| inputs: | |
| new_branch: | |
| description: 'New Branch' | |
| required: false | |
| type: string | |
| new_version: | |
| description: 'New Minecraft Version' | |
| required: false | |
| type: string | |
| update_tools: | |
| default: true | |
| type: boolean | |
| publish: | |
| required: false | |
| default: false | |
| type: boolean | |
| workflow_dispatch: | |
| inputs: | |
| new_branch: | |
| description: 'New Branch' | |
| required: false | |
| new_version: | |
| description: 'New Minecraft Version' | |
| required: false | |
| update_tools: | |
| description: 'Update Tools to Latest Versions' | |
| required: false | |
| default: true | |
| type: boolean | |
| publish: | |
| description: 'Publish' | |
| required: false | |
| default: false | |
| type: boolean | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| jobs: | |
| update: | |
| name: Update | |
| runs-on: ubuntu-latest | |
| # We are using environment variables here since that lets the shell take care of escaping them as CLI params. | |
| env: | |
| NEW_BRANCH: ${{ inputs.new_branch }} | |
| NEW_VERSION: ${{ inputs.new_version }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Java 21 | |
| uses: neoforged/actions/setup-java@main | |
| with: | |
| java-version: 21 | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v4 | |
| - name: Create new Branch | |
| if: ${{ inputs.new_branch }} | |
| run: git checkout -b "$NEW_BRANCH" || git checkout -B ${{ inputs.new_branch }} HEAD | |
| - name: Update Tools | |
| if: ${{ inputs.update_tools }} | |
| run: ./gradlew updateTools | |
| - name: Update Minecraft Version | |
| if: ${{ inputs.new_version }} | |
| run: ./gradlew -- updateMinecraft "--version=$NEW_VERSION" | |
| - name: Update Patches | |
| run: ./gradlew createPatchWorkspaceForUpdate && ./gradlew createPatches | |
| - name: Commit Changes | |
| # See https://github.com/actions/checkout?tab=readme-ov-file#push-a-commit-using-the-built-in-token | |
| id: commit-changes | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git add . | |
| if git diff --staged --quiet; then | |
| echo "No changes to commit" | |
| else | |
| git commit -m "$COMMIT_MESSAGE" | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| fi | |
| env: | |
| COMMIT_MESSAGE: ${{ inputs.new_version && format('Update to {0}', inputs.new_version) || (inputs.update_tools && 'Update Tools' || 'Update') }} | |
| - name: Push Changes | |
| if: steps.commit-changes.outputs.changed | |
| run: git push -u origin HEAD | |
| - name: Trigger Publish Workflow | |
| if: inputs.publish && steps.commit-changes.outputs.changed | |
| uses: actions/github-script@v8 | |
| # We need to use environment variables here to avoid untrusted input injection into the javascript code below. | |
| env: | |
| BRANCH_REF: ${{ inputs.new_branch || github.ref_name }} | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| await github.rest.actions.createWorkflowDispatch({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| workflow_id: 'publish.yml', | |
| ref: process.env.BRANCH_REF, | |
| inputs: { | |
| release: 'true' | |
| } | |
| }); |