11# Experimental workflow to automate updating to a new Minecraft snapshot.
2-
3- # Currently this is very similar to the semi-automatic scripts I already use,
4- # but moving them to GitHub Actions means I don't have to be around to start
5- # them. This should allow for further automation in the future.
6-
7- # TODO:
8- # - Add more thorough automated testing where it runs the game, creates a test
9- # world and takes screenshots, similar to what Fabric API does in their
10- # GitHub Actions workflow.
11- # - Set up a server to trigger this workflow when a new snapshot is out and
12- # Fabric has updated to it. This might end up running twice per snapshot,
13- # because there is no way to know ahead of time if the previous Fabric API
14- # build still works or if we have to wait for a new build made specifically
15- # for the new snapshot.
16- # - Add a step to automatically release the new snapshot build if all tests
17- # have passed. This will only ever run on small snapshots that don't break
18- # anything, but should save a ton of time at the end of each snapshot cycle
19- # when Mojang is spamming tiny pre-releases every day.
20-
21- # In case it isn't obvious, these todos are very ambitious and might not end
22- # up working as planned.
23-
242name : Auto Snapshot Update
253
264on :
3917 description : " Fabric API version"
4018 required : true
4119 distinct_id :
42- description : " Automatically set by the return-dispatch action (leave blank if running manually)"
4320 required : false
4421
4522permissions :
5330 runs-on : ubuntu-latest
5431 steps :
5532
56- - name : Echo distinct ID ${{ github.event. inputs.distinct_id }}
57- run : echo ${{ github.event. inputs.distinct_id }}
33+ - name : Echo distinct ID ${{ inputs.distinct_id }}
34+ run : echo ${{ inputs.distinct_id }}
5835
5936 - name : Checkout repository
6037 uses : actions/checkout@v5
@@ -79,23 +56,28 @@ jobs:
7956 build-scan-publish : true
8057 build-scan-terms-of-use-url : " https://gradle.com/help/legal-terms-of-use"
8158 build-scan-terms-of-use-agree : " yes"
59+ cache-encryption-key : ${{ secrets.GRADLE_ENCRYPTION_KEY }}
60+ cache-read-only : ${{ github.ref != 'refs/heads/master' && !startsWith(github.ref, 'refs/heads/1.') }}
8261
83- - name : Run migrateMappings task
62+ - name : Migrate mappings for main source set
8463 run : |
85- ./gradlew migrateMappings --mappings ${{ github.event.inputs.yarn_mappings }}
64+ ./gradlew migrateMappings --mappings ${{ inputs.yarn_mappings }} --input "src/main/java" --output "src/main/java_"
65+ rm -rf ./src/main/java
66+ mv ./src/main/java_ ./src/main/java
8667
87- - name : Replace src/main/java with remapped files
68+ - name : Migrate mappings for test source set
8869 run : |
89- rm -rf ./src/main/java
90- mv ./remappedSrc ./src/main/java
70+ ./gradlew migrateMappings --mappings ${{ inputs.yarn_mappings }} --input "src/test/java" --output "src/test/java_"
71+ rm -rf ./src/test/java
72+ mv ./src/test/java_ ./src/test/java
9173
9274 - name : Update version constants
9375 run : |
9476 python scripts/update_version_constants.py \
95- "${{ github.event. inputs.mc_version }}" \
96- "${{ github.event. inputs.yarn_mappings }}" \
97- "${{ github.event. inputs.fabric_loader }}" \
98- "${{ github.event. inputs.fapi_version }}"
77+ "${{ inputs.mc_version }}" \
78+ "${{ inputs.yarn_mappings }}" \
79+ "${{ inputs.fabric_loader }}" \
80+ "${{ inputs.fapi_version }}"
9981
10082 # To fix any style issues that the migration scripts might cause
10183 - name : Run spotlessApply task
@@ -106,24 +88,15 @@ jobs:
10688 git config --global user.name "Wurst-Bot"
10789 git config --global user.email "[email protected] " 10890 git add .
109- git commit -m "[Wurst-Bot] Update to ${{ github.event. inputs.mc_version }}"
91+ git commit -m "[Wurst-Bot] Update to ${{ inputs.mc_version }}"
11092 git push
11193
11294 - name : Trigger CI
113- id : ci_dispatch
114- uses : codex-/return-dispatch@v2
95+ uses : Wurst-Imperium/dispatch-and-wait@v1
11596 with :
11697 token : ${{ github.token }}
117- owner : Wurst-Imperium
118- repo : Wurst7
98+ owner : ${{ github.repository_owner }}
99+ repo : ${{ github.event.repository.name }}
119100 ref : ${{ github.ref }}
120101 workflow : gradle.yml
121-
122- - name : Wait for CI to finish (run ${{ steps.ci_dispatch.outputs.run_id }})
123- uses : codex-/await-remote-run@v1
124- with :
125- token : ${{ github.token }}
126- owner : Wurst-Imperium
127- repo : Wurst7
128- run_id : ${{ steps.ci_dispatch.outputs.run_id }}
129102 run_timeout_seconds : 600 # 10 minutes
0 commit comments