-
-
Notifications
You must be signed in to change notification settings - Fork 0
260 lines (254 loc) · 10.6 KB
/
multi_auto_snapshot_update.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
name: Run Auto Snapshot Update Workflows
on:
workflow_dispatch:
inputs:
mc_version:
description: "Target Minecraft version (leave blank to auto detect)"
required: false
prev_mc_version:
description: "Previous 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_versions.outputs.mc_version }}
prev_mc_version: ${{ steps.get_mc_versions.outputs.prev_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 and previous MC versions
id: get_mc_versions
run: |
MC_VERSION="${{ inputs.mc_version }}"
PREV_MC_VERSION="${{ inputs.prev_mc_version }}"
if [ -z "$MC_VERSION" ] || [ -z "$PREV_MC_VERSION" ]; then
RESPONSE=$(curl -s https://launchermeta.mojang.com/mc/game/version_manifest.json)
if [ -z "$MC_VERSION" ]; then
MC_VERSION=$(echo "$RESPONSE" | jq -r '.latest.snapshot')
if [ -z "$MC_VERSION" ]; then
echo "No latest Minecraft snapshot found"
echo "Response: $RESPONSE"
exit 1
fi
fi
if [ -z "$PREV_MC_VERSION" ]; then
PREV_MC_VERSION=$(echo "$RESPONSE" | jq -r --arg MC_VERSION "$MC_VERSION" '.versions | map(select(.id != $MC_VERSION)) | .[0].id')
if [ -z "$PREV_MC_VERSION" ]; then
echo "No previous Minecraft version found"
echo "Response: $RESPONSE"
exit 1
fi
fi
fi
echo "mc_version=$MC_VERSION" >> $GITHUB_OUTPUT
echo "prev_mc_version=$PREV_MC_VERSION" >> $GITHUB_OUTPUT
echo "Minecraft version: \`$MC_VERSION\`" >> $GITHUB_STEP_SUMMARY
echo "Previous version: \`$PREV_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_versions.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_versions.outputs.mc_version }}"
echo "Response: $RESPONSE"
exit 1
fi
- name: Get Fabric API version
id: get_fapi_version
run: |
FAPI_VERSION="${{ inputs.fapi_version }}"
if [ -z "$FAPI_VERSION" ]; then
MC_VERSION="${{ steps.get_mc_versions.outputs.mc_version }}"
if [ -z "${{ secrets.GITHUB_TOKEN }}" ]; then
echo "GitHub token is not set"
exit 1
fi
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")
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"
echo "Response: $RESPONSE"
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
# CfCore is the _other_ CurseForge API, see https://console.curseforge.com/#/api-keys
if [ -z "${{ secrets.CFCORE_API_KEY }}" ]; then
echo "CfCore API key is not set"
exit 1
fi
# Must use single quotes here because the API keys contain $
RESPONSE=$(curl -s -w "%{http_code}" \
-H "Accept: application/json" \
-H 'x-api-key: ${{ secrets.CFCORE_API_KEY }}' \
"https://api.curseforge.com/v1/mods/306612/files")
STATUS_CODE=${RESPONSE: -3}
BODY=${RESPONSE::-3}
CF_GAME_VERSION=$(echo "$BODY" \
| jq -r '.data[0].gameVersions[] | select(. != "Fabric")')
if [ -z "$CF_GAME_VERSION" ]; then
echo "No CurseForge game version found for ${{ steps.get_mc_versions.outputs.mc_version }}"
echo "Status code: $STATUS_CODE"
echo "Response: $BODY"
exit 1
fi
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.prev_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.prev_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.prev_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