Run Auto Snapshot Update Workflows #1
This file contains 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: Run Auto Snapshot Update Workflows | |
on: | |
workflow_dispatch: | |
inputs: | |
mc_version: | |
description: "Target Minecraft version (leave blank to auto detect)" | |
required: false | |
fapi_version: | |
description: "Fabric API version (leave blank to auto detect)" | |
required: false | |
cf_game_version: | |
description: "CurseForge game version (leave blank to auto detect)" | |
required: false | |
include_wurst: | |
description: "Include Wurst Client" | |
type: boolean | |
required: false | |
default: true | |
include_wi_zoom: | |
description: "Include WI Zoom" | |
type: boolean | |
required: false | |
default: true | |
include_mo_glass: | |
description: "Include Mo Glass" | |
type: boolean | |
required: false | |
default: true | |
jobs: | |
get_params: | |
runs-on: ubuntu-latest | |
outputs: | |
mc_version: ${{ steps.get_mc_version.outputs.mc_version }} | |
yarn_version: ${{ steps.get_yarn_and_loader.outputs.yarn_version }} | |
loader_version: ${{ steps.get_yarn_and_loader.outputs.loader_version }} | |
fapi_version: ${{ steps.get_fapi_version.outputs.fapi_version }} | |
cf_game_version: ${{ steps.get_cf_game_version.outputs.cf_game_version }} | |
steps: | |
- name: Get target MC version | |
id: get_mc_version | |
run: | | |
MC_VERSION="${{ inputs.mc_version }}" | |
if [ -z "$MC_VERSION" ]; then | |
MC_VERSION=$(curl -s https://launchermeta.mojang.com/mc/game/version_manifest.json \ | |
| jq -r '.latest.snapshot') | |
fi | |
echo "mc_version=$MC_VERSION" >> $GITHUB_OUTPUT | |
echo "Minecraft version: \`$MC_VERSION\`" >> $GITHUB_STEP_SUMMARY | |
- name: Get Yarn and Loader versions | |
id: get_yarn_and_loader | |
run: | | |
RESPONSE=$(curl -s \ | |
"https://meta.fabricmc.net/v1/versions/loader/${{ steps.get_mc_version.outputs.mc_version }}") | |
if [ "$(echo "$RESPONSE" | jq length)" -gt 0 ]; then | |
YARN_VERSION=$(echo "$RESPONSE" | jq -r '.[0].mappings.version') | |
LOADER_VERSION=$(echo "$RESPONSE" | jq -r '.[0].loader.version') | |
echo "yarn_version=$YARN_VERSION" >> $GITHUB_OUTPUT | |
echo "loader_version=$LOADER_VERSION" >> $GITHUB_OUTPUT | |
echo "Yarn version: \`$YARN_VERSION\`" >> $GITHUB_STEP_SUMMARY | |
echo "Loader version: \`$LOADER_VERSION\`" >> $GITHUB_STEP_SUMMARY | |
else | |
echo "No yarn/loader versions found for ${{ steps.get_mc_version.outputs.mc_version }}" | |
exit 1 | |
fi | |
- name: Get Fabric API version | |
id: get_fapi_version | |
run: | | |
FAPI_VERSION="${{ inputs.fapi_version }}" | |
if [ -z "$FAPI_VERSION" ]; then | |
RESPONSE=$(curl -s \ | |
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
"https://api.github.com/repos/FabricMC/fabric/releases?per_page=100") | |
MC_VERSION="${{ steps.get_mc_version.outputs.mc_version }}" | |
FAPI_VERSION=$(echo "$RESPONSE" \ | |
| jq -r --arg MC_VERSION "$MC_VERSION" \ | |
'.[] | select(.name | contains($MC_VERSION)) | .tag_name' \ | |
| head -n 1) | |
if [ -z "$FAPI_VERSION" ]; then | |
echo "No Fabric API version found for $MC_VERSION" | |
exit 1 | |
fi | |
fi | |
echo "fapi_version=$FAPI_VERSION" >> $GITHUB_OUTPUT | |
echo "Fabric API version: \`$FAPI_VERSION\`" >> $GITHUB_STEP_SUMMARY | |
- name: Get CurseForge game version | |
id: get_cf_game_version | |
run: | | |
CF_GAME_VERSION="${{ inputs.cf_game_version }}" | |
if [ -z "$CF_GAME_VERSION" ]; then | |
CF_GAME_VERSION=$(curl -s \ | |
-H "Accept: application/json" \ | |
-H "x-api-key: ${{ secrets.CURSEFORGE_API_KEY }}" \ | |
"https://api.curseforge.com/v1/games/minecraft/mods/306612/files?pageSize=1" \ | |
| jq -r '.data[0].gameVersions[] | select(. != "Fabric")') | |
fi | |
echo "cf_game_version=$CF_GAME_VERSION" >> $GITHUB_OUTPUT | |
echo "CurseForge game version: \`$CF_GAME_VERSION\`" >> $GITHUB_STEP_SUMMARY | |
wurst: | |
runs-on: ubuntu-latest | |
needs: get_params | |
if: ${{ inputs.include_wurst }} | |
steps: | |
- name: Build Wurst update inputs | |
id: wurst_inputs | |
run: | | |
JSON_STRING=$(cat << EOF | |
{ | |
"mc_version": "${{ needs.get_params.outputs.mc_version }}", | |
"yarn_mappings": "${{ needs.get_params.outputs.yarn_version }}", | |
"fabric_loader": "${{ needs.get_params.outputs.loader_version }}", | |
"fapi_version": "${{ needs.get_params.outputs.fapi_version }}" | |
} | |
EOF | |
) | |
# Convert to single line and escape quotes | |
echo "json=${JSON_STRING//$'\n'/}" >> $GITHUB_OUTPUT | |
- name: Trigger snapshot update workflow | |
id: wurst_dispatch | |
uses: codex-/return-dispatch@v2 | |
with: | |
token: ${{ secrets.SNAPSHOT_MODS_ACTIONS_TOKEN }} | |
owner: Wurst-Imperium | |
repo: Wurst7 | |
ref: ${{ needs.get_params.outputs.mc_version }} | |
workflow: auto_snapshot_update.yml | |
workflow_inputs: ${{ steps.wurst_inputs.outputs.json }} | |
- name: Wait for snapshot update workflow to finish (run ${{ steps.wurst_dispatch.outputs.run_id }}) | |
uses: codex-/await-remote-run@v1 | |
with: | |
token: ${{ secrets.SNAPSHOT_MODS_ACTIONS_TOKEN }} | |
owner: Wurst-Imperium | |
repo: Wurst7 | |
run_id: ${{ steps.wurst_dispatch.outputs.run_id }} | |
run_timeout_seconds: 600 # 10 minutes | |
wi_zoom: | |
runs-on: ubuntu-latest | |
needs: get_params | |
if: ${{ inputs.include_wi_zoom }} | |
steps: | |
- name: Build WI Zoom update inputs | |
id: wi_zoom_inputs | |
run: | | |
JSON_STRING=$(cat << EOF | |
{ | |
"mc_version": "${{ needs.get_params.outputs.mc_version }}", | |
"yarn_mappings": "${{ needs.get_params.outputs.yarn_version }}", | |
"fabric_loader": "${{ needs.get_params.outputs.loader_version }}", | |
"fapi_version": "${{ needs.get_params.outputs.fapi_version }}", | |
"cf_game_version": "${{ needs.get_params.outputs.cf_game_version }}" | |
} | |
EOF | |
) | |
# Convert to single line and escape quotes | |
echo "json=${JSON_STRING//$'\n'/}" >> $GITHUB_OUTPUT | |
- name: Trigger snapshot update workflow | |
id: wi_zoom_dispatch | |
uses: codex-/return-dispatch@v2 | |
with: | |
token: ${{ secrets.SNAPSHOT_MODS_ACTIONS_TOKEN }} | |
owner: Wurst-Imperium | |
repo: WI-Zoom | |
ref: ${{ needs.get_params.outputs.mc_version }} | |
workflow: auto_snapshot_update.yml | |
workflow_inputs: ${{ steps.wi_zoom_inputs.outputs.json }} | |
- name: Wait for snapshot update workflow to finish (run ${{ steps.wi_zoom_dispatch.outputs.run_id }}) | |
uses: codex-/await-remote-run@v1 | |
with: | |
token: ${{ secrets.SNAPSHOT_MODS_ACTIONS_TOKEN }} | |
owner: Wurst-Imperium | |
repo: WI-Zoom | |
run_id: ${{ steps.wi_zoom_dispatch.outputs.run_id }} | |
run_timeout_seconds: 600 # 10 minutes | |
mo_glass: | |
runs-on: ubuntu-latest | |
needs: get_params | |
if: ${{ inputs.include_mo_glass }} | |
steps: | |
- name: Build Mo Glass update inputs | |
id: mo_glass_inputs | |
run: | | |
JSON_STRING=$(cat << EOF | |
{ | |
"mc_version": "${{ needs.get_params.outputs.mc_version }}", | |
"yarn_mappings": "${{ needs.get_params.outputs.yarn_version }}", | |
"fabric_loader": "${{ needs.get_params.outputs.loader_version }}", | |
"fapi_version": "${{ needs.get_params.outputs.fapi_version }}", | |
"cf_game_version": "${{ needs.get_params.outputs.cf_game_version }}" | |
} | |
EOF | |
) | |
# Convert to single line and escape quotes | |
echo "json=${JSON_STRING//$'\n'/}" >> $GITHUB_OUTPUT | |
- name: Trigger snapshot update workflow | |
id: mo_glass_dispatch | |
uses: codex-/return-dispatch@v2 | |
with: | |
token: ${{ secrets.SNAPSHOT_MODS_ACTIONS_TOKEN }} | |
owner: Wurst-Imperium | |
repo: Mo-Glass | |
ref: ${{ needs.get_params.outputs.mc_version }} | |
workflow: auto_snapshot_update.yml | |
workflow_inputs: ${{ steps.mo_glass_inputs.outputs.json }} | |
- name: Wait for snapshot update workflow to finish (run ${{ steps.mo_glass_dispatch.outputs.run_id }}) | |
uses: codex-/await-remote-run@v1 | |
with: | |
token: ${{ secrets.SNAPSHOT_MODS_ACTIONS_TOKEN }} | |
owner: Wurst-Imperium | |
repo: Mo-Glass | |
run_id: ${{ steps.mo_glass_dispatch.outputs.run_id }} | |
run_timeout_seconds: 600 # 10 minutes |