|
| 1 | +# Experimental workflow to automate updating to a new Minecraft snapshot. |
| 2 | +name: Auto Snapshot Update |
| 3 | + |
| 4 | +on: |
| 5 | + workflow_dispatch: |
| 6 | + inputs: |
| 7 | + mc_version: |
| 8 | + description: "Minecraft version to update to" |
| 9 | + required: true |
| 10 | + yarn_mappings: |
| 11 | + description: "Yarn mappings version" |
| 12 | + required: true |
| 13 | + fabric_loader: |
| 14 | + description: "Fabric Loader version" |
| 15 | + required: true |
| 16 | + fapi_version: |
| 17 | + description: "Fabric API version" |
| 18 | + required: true |
| 19 | + distinct_id: |
| 20 | + description: "Automatically set by the return-dispatch action (leave blank if running manually)" |
| 21 | + required: false |
| 22 | + |
| 23 | +permissions: |
| 24 | + # To push changes to the snapshot branch. |
| 25 | + contents: write |
| 26 | + # To trigger the CI workflow. |
| 27 | + actions: write |
| 28 | + |
| 29 | +jobs: |
| 30 | + update: |
| 31 | + runs-on: ubuntu-latest |
| 32 | + steps: |
| 33 | + |
| 34 | + - name: Echo distinct ID ${{ inputs.distinct_id }} |
| 35 | + run: echo ${{ inputs.distinct_id }} |
| 36 | + |
| 37 | + - name: Checkout repository |
| 38 | + uses: actions/checkout@v5 |
| 39 | + |
| 40 | + - name: Set up Python 3.12 |
| 41 | + uses: actions/setup-python@v6 |
| 42 | + with: |
| 43 | + python-version: "3.12" |
| 44 | + |
| 45 | + - name: Set up Java 21 |
| 46 | + uses: actions/setup-java@v5 |
| 47 | + with: |
| 48 | + java-version: "21" |
| 49 | + distribution: "microsoft" |
| 50 | + |
| 51 | + - name: Grant execute permission for gradlew |
| 52 | + run: chmod +x gradlew |
| 53 | + |
| 54 | + - name: Setup Gradle |
| 55 | + uses: gradle/actions/setup-gradle@v4 |
| 56 | + with: |
| 57 | + build-scan-publish: true |
| 58 | + build-scan-terms-of-use-url: "https://gradle.com/help/legal-terms-of-use" |
| 59 | + build-scan-terms-of-use-agree: "yes" |
| 60 | + |
| 61 | + - name: Migrate mappings for main source set |
| 62 | + run: | |
| 63 | + ./gradlew migrateMappings --mappings ${{ inputs.yarn_mappings }} --input "src/main/java" --output "src/main/java_" |
| 64 | + rm -rf ./src/main/java |
| 65 | + mv ./src/main/java_ ./src/main/java |
| 66 | +
|
| 67 | + - name: Migrate mappings for test source set |
| 68 | + run: | |
| 69 | + ./gradlew migrateMappings --mappings ${{ inputs.yarn_mappings }} --input "src/test/java" --output "src/test/java_" |
| 70 | + rm -rf ./src/test/java |
| 71 | + mv ./src/test/java_ ./src/test/java |
| 72 | +
|
| 73 | + - name: Update version constants |
| 74 | + run: | |
| 75 | + python scripts/update_version_constants.py \ |
| 76 | + "${{ inputs.mc_version }}" \ |
| 77 | + "${{ inputs.yarn_mappings }}" \ |
| 78 | + "${{ inputs.fabric_loader }}" \ |
| 79 | + "${{ inputs.fapi_version }}" |
| 80 | +
|
| 81 | + # To fix any style issues that the migration scripts might cause |
| 82 | + - name: Run spotlessApply task |
| 83 | + run: ./gradlew spotlessApply |
| 84 | + |
| 85 | + - name: Commit and push changes |
| 86 | + run: | |
| 87 | + git config --global user.name "Wurst-Bot" |
| 88 | + git config --global user.email "contact.wurstimperium@gmail.com" |
| 89 | + git add . |
| 90 | + git commit -m "[Wurst-Bot] Update to ${{ inputs.mc_version }}" |
| 91 | + git push |
| 92 | +
|
| 93 | + - name: Trigger CI |
| 94 | + id: ci_dispatch |
| 95 | + uses: codex-/return-dispatch@v2 |
| 96 | + with: |
| 97 | + token: ${{ github.token }} |
| 98 | + owner: Wurst-Imperium |
| 99 | + repo: ${{ github.event.repository.name }} |
| 100 | + ref: ${{ github.ref }} |
| 101 | + workflow: gradle.yml |
| 102 | + |
| 103 | + - name: Wait for CI to finish (run ${{ steps.ci_dispatch.outputs.run_id }}) |
| 104 | + uses: codex-/await-remote-run@v1 |
| 105 | + with: |
| 106 | + token: ${{ github.token }} |
| 107 | + owner: Wurst-Imperium |
| 108 | + repo: ${{ github.event.repository.name }} |
| 109 | + run_id: ${{ steps.ci_dispatch.outputs.run_id }} |
| 110 | + run_timeout_seconds: 600 # 10 minutes |
0 commit comments