-
Notifications
You must be signed in to change notification settings - Fork 2
302 lines (276 loc) · 13.4 KB
/
lifecycle.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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
---
name: Lifecycle
"on":
push:
branches:
- main
pull_request:
types:
- closed
- opened
- synchronize
- reopened
workflow_dispatch:
inputs:
dirs:
description: Comma-delimited directories to build and run (i.e. api,1_20,1_21 )
default: "all"
ref:
description: Git ref to checkout before build (i.e. my-feature-branch )
default: "main"
concurrency: # FIXME: prevent release commit cancellation
group: >
${{ github.workflow }}-
${{ github.event_name }}-
${{ github.event.inputs.ref || github.ref }}
cancel-in-progress: true
jobs:
release-please:
name: Release Please
runs-on: ubuntu-22.04
outputs:
release_created: ${{ steps.release-please.outputs.release_created }}
tag_name: ${{ steps.release-please.outputs.tag_name }}
permissions:
contents: write
pull-requests: write
steps:
- if: github.event_name == 'push' # TODO: explicit on push to main
id: release-please
name: Run Release Please
uses: googleapis/release-please-action@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
matrices:
if: github.event.action != 'closed'
name: Construct matrices
needs: release-please
runs-on: ubuntu-22.04
outputs:
build-matrix: ${{ steps.matrices.outputs.build-matrix }}
run-matrix: ${{ steps.matrices.outputs.run-matrix }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
ref: ${{ inputs.ref || github.ref }}
- if: github.event_name != 'workflow_dispatch'
id: paths
name: Get paths
run: |
{ delimiter="$(openssl rand -hex 8)"
echo "filter<<${delimiter}"
for dir in $(find . -maxdepth 1 -type d -not -path "./.git*" -print | cut -d/ -f2-); do
echo "'$dir' : ['$dir/**']"
done; echo "${delimiter}"; } >> "${GITHUB_OUTPUT}"
echo "${GITHUB_OUTPUT}"
cat "${GITHUB_OUTPUT}" || true
- if: github.event_name != 'workflow_dispatch'
id: filter
name: Filter
uses: dorny/[email protected]
with:
filters: |
${{ steps.paths.outputs.filter }}
- id: matrices # TODO: build origin matrices dynamically, consider collapsing this into a .py
name: Construct matrices
run: |
import os
import json
build_matrix = {"include": []}
run_matrix = {"version": []}
build_data = [
{"dir": "api", "java": "8"},
{"dir": "1_21", "mc": "1.21.3", "lex": "53.0.7", "neo": "11-beta", "java": "21"},
{"dir": "1_21", "mc": "1.21.1", "lex": "52.0.2", "neo": "4", "java": "21"},
{"dir": "1_21", "mc": "1.21", "lex": "51.0.24", "neo": "96-beta", "java": "21"},
{"dir": "1_20/1_20_6", "mc": "1.20.6", "lex": "50.1.10", "neo": "119", "java": "21"},
{"dir": "1_20", "mc": "1.20.4", "lex": "49.0.38", "neo": "219", "java": "17"},
{"dir": "1_20", "mc": "1.20.3", "lex": "49.0.2", "neo": "8-beta", "java": "17"},
{"dir": "1_20", "mc": "1.20.2", "lex": "48.1.0", "neo": "88", "java": "17"},
{"dir": "1_20/1_20_1", "mc": "1.20.1", "lex": "47.2.23", "java": "17"},
{"dir": "1_19", "mc": "1.19.4", "lex": "45.2.9", "java": "17"},
{"dir": "1_19", "mc": "1.19.3", "lex": "44.1.23", "java": "17"},
{"dir": "1_19", "mc": "1.19.2", "lex": "43.3.9", "java": "17"},
{"dir": "1_19", "mc": "1.19.1", "lex": "42.0.9", "java": "17"},
{"dir": "1_19", "mc": "1.19", "lex": "41.1.0", "java": "17"},
{"dir": "1_18", "mc": "1.18.2", "lex": "40.2.18", "java": "17"},
{"dir": "1_17", "mc": "1.17.1", "lex": "37.1.1", "java": "16"},
{"dir": "1_16", "mc": "1.16.5", "lex": "36.2.42", "java": "8"},
{"dir": "1_12", "mc": "1.12.2", "lex": "14.23.5.2860", "java": "8"},
{"dir": "1_8_9", "mc": "1.8.9", "lex": "11.15.1.2318-1.8.9", "java": "8"},
{"dir": "1_7_10", "mc": "1.7.10", "lex": "10.13.4.1614-1.7.10", "java": "8"}
]
run_data = [
{"mc": "1.21.3", "type": "lexforge", "modloader": "forge", "regex": ".*forge.*", "java": "21"},
{"mc": "1.21.3", "type": "neoforge", "modloader": "neoforge", "regex": ".*neoforge.*", "java": "21"},
{"mc": "1.21.3", "type": "fabric", "modloader": "fabric", "regex": ".*fabric.*", "java": "21"},
{"mc": "1.21.1", "type": "lexforge", "modloader": "forge", "regex": ".*forge.*", "java": "21"},
{"mc": "1.21.1", "type": "neoforge", "modloader": "neoforge", "regex": ".*neoforge.*", "java": "21"},
{"mc": "1.21.1", "type": "fabric", "modloader": "fabric", "regex": ".*fabric.*", "java": "21"},
{"mc": "1.21", "type": "lexforge", "modloader": "forge", "regex": ".*forge.*", "java": "21"},
{"mc": "1.21", "type": "neoforge", "modloader": "neoforge", "regex": ".*neoforge.*", "java": "21"},
{"mc": "1.21", "type": "fabric", "modloader": "fabric", "regex": ".*fabric.*", "java": "21"},
{"mc": "1.20.6", "type": "lexforge", "modloader": "forge", "regex": ".*forge.*", "java": "21"},
{"mc": "1.20.6", "type": "neoforge", "modloader": "neoforge", "regex": ".*neoforge.*", "java": "21"},
{"mc": "1.20.6", "type": "fabric", "modloader": "fabric", "regex": ".*fabric.*", "java": "21"},
{"mc": "1.20.4", "type": "lexforge", "modloader": "forge", "regex": ".*forge.*", "java": "17"},
{"mc": "1.20.4", "type": "neoforge", "modloader": "neoforge", "regex": ".*neoforge.*", "java": "17"},
{"mc": "1.20.4", "type": "fabric", "modloader": "fabric", "regex": ".*fabric.*", "java": "17"},
{"mc": "1.20.3", "type": "lexforge", "modloader": "forge", "regex": ".*forge.*", "java": "17"},
{"mc": "1.20.3", "type": "neoforge", "modloader": "neoforge", "regex": ".*neoforge.*", "java": "17"},
{"mc": "1.20.3", "type": "fabric", "modloader": "fabric", "regex": ".*fabric.*", "java": "17"},
{"mc": "1.20.2", "type": "lexforge", "modloader": "forge", "regex": ".*forge.*", "java": "17"},
{"mc": "1.20.2", "type": "neoforge", "modloader": "neoforge", "regex": ".*neoforge.*", "java": "17"},
{"mc": "1.20.2", "type": "fabric", "modloader": "fabric", "regex": ".*fabric.*", "java": "17"},
{"mc": "1.20.1", "type": "lexforge", "modloader": "forge", "regex": ".*forge.*", "java": "17"},
{"mc": "1.20.1", "type": "fabric", "modloader": "fabric", "regex": ".*fabric.*", "java": "17"},
{"mc": "1.19.4", "type": "fabric", "modloader": "fabric", "regex": ".*fabric.*", "java": "17"},
{"mc": "1.19.4", "type": "lexforge", "modloader": "forge", "regex": ".*forge.*", "java": "17"},
{"mc": "1.19.3", "type": "fabric", "modloader": "fabric", "regex": ".*fabric.*", "java": "17"},
{"mc": "1.19.3", "type": "lexforge", "modloader": "forge", "regex": ".*forge.*", "java": "17"},
{"mc": "1.19.2", "type": "fabric", "modloader": "fabric", "regex": ".*fabric.*", "java": "17"},
{"mc": "1.19.2", "type": "lexforge", "modloader": "forge", "regex": ".*forge.*", "java": "17"},
{"mc": "1.19.1", "type": "fabric", "modloader": "fabric", "regex": ".*fabric.*", "java": "17"},
{"mc": "1.19.1", "type": "lexforge", "modloader": "forge", "regex": ".*forge.*", "java": "17"},
{"mc": "1.19", "type": "fabric", "modloader": "fabric", "regex": ".*fabric.*", "java": "17"},
{"mc": "1.19", "type": "lexforge", "modloader": "forge", "regex": ".*forge.*", "java": "17"},
{"mc": "1.18.2", "type": "fabric", "modloader": "fabric", "regex": ".*fabric.*", "java": "17"},
{"mc": "1.18.2", "type": "lexforge", "modloader": "forge", "regex": ".*forge.*", "java": "17"},
{"mc": "1.17.1", "type": "fabric", "modloader": "fabric", "regex": ".*fabric.*", "java": "16"},
{"mc": "1.17.1", "type": "lexforge", "modloader": "forge", "regex": ".*forge.*", "java": "16"},
{"mc": "1.16.5", "type": "fabric", "modloader": "fabric", "regex": ".*fabric.*", "java": "8"},
{"mc": "1.16.5", "type": "lexforge", "modloader": "forge", "regex": ".*forge.*", "java": "8"},
{"mc": "1.12.2", "type": "lexforge", "modloader": "forge", "regex": ".*forge.*", "java": "8"},
{"mc": "1.8.9", "type": "lexforge", "modloader": "forge", "regex": ".*orge.*", "java": "8"},
{"mc": "1.7.10", "type": "lexforge", "modloader": "forge", "regex": ".*orge.*", "java": "8"}
]
dirs_to_filter = []
match os.getenv('GITHUB_EVENT_NAME'):
case 'pull_request':
if "${{ steps.filter.outcome }}" == "success":
# Filter matrices based on the detected changes
dirs_to_filter = json.loads('${{ steps.filter.outputs.changes }}')
case 'workflow_dispatch':
input_dirs = '${{ github.event.inputs.dirs }}'
print(input_dirs)
if input_dirs == 'all':
# If "all" is specified in the input, run all possible builds and runs
build_matrix['include'], run_matrix['version'] = build_data, run_data
print(build_matrix)
print(run_matrix)
else:
# Otherwise, filter based on the directories listed in the input
dirs_to_filter = [item.strip() for item in input_dirs.split(',')]
case 'push':
if '${{ needs.release-please.outputs.release_created }}' == 'true':
# If a release is created, use the full matrices
build_matrix['include'], run_matrix['version'] = build_data, run_data
if dirs_to_filter:
build_matrix['include'].extend([item for item in build_data if item["dir"] in dirs_to_filter])
mc_versions = [item.get("mc") for item in build_matrix["include"] if "mc" in item]
run_matrix['version'].extend([item for item in run_data if item["mc"] in mc_versions])
with open(os.environ['GITHUB_OUTPUT'], 'a') as fh:
print(json.dumps(build_matrix, indent=2))
fh.write(f'build-matrix={json.dumps(build_matrix)}\n')
print(json.dumps(run_matrix, indent=2))
fh.write(f'run-matrix={json.dumps(run_matrix)}\n')
shell: python {0}
build:
if: fromJSON(needs.matrices.outputs.build-matrix).include[0] != null
name: Build
needs: matrices
strategy:
fail-fast: false
matrix:
${{ insert }}: ${{ fromJSON(needs.matrices.outputs.build-matrix) }}
uses: ./.github/workflows/flex-build.yml
with:
dir: ${{ matrix.dir }}
mc: ${{ matrix.mc }}
lex: ${{ matrix.lex }}
neo: ${{ matrix.neo }}
java: ${{ matrix.java }}
run:
if: github.event_name != 'push'
name: Run tests
needs:
- matrices
- build
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
${{ insert }}: ${{ fromJSON(needs.matrices.outputs.run-matrix) }}
xvfb: [true, false]
steps:
- name: Checkout # TODO: simplify away this step, currently needed for `uses: ./`
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: jars-${{ matrix.version.mc }}
- name: Bootstrap mods
run: |
mkdir -p run/mods
cp mc-runtime-test-*-${{ matrix.version.type }}-release.jar run/mods
- name: Setup Java temurin-${{ matrix.version.java }}
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.version.java }}
distribution: temurin
- name: Run game
timeout-minutes: 3
uses: ./
with:
mc: ${{ matrix.version.mc }}
mc-runtime-test: none
modloader: ${{ matrix.version.modloader }}
regex: ${{ matrix.version.regex }}
java: ${{ matrix.version.java }}
xvfb: ${{ matrix.xvfb }}
headlessmc-command: ${{ !matrix.xvfb && '-lwjgl' || '' }} --retries 3 --jvm -Djava.awt.headless=true
release:
if: needs.release-please.outputs.release_created == 'true'
needs:
- release-please
- build
name: Release
permissions:
contents: write
runs-on: ubuntu-22.04
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
- name: Upload release artifacts
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: jars-*/*-release.jar
tag: ${{ needs.release-please.outputs.tag_name }}
overwrite: true
file_glob: true
- name: Upload api artifacts
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: jars-*/*-api-*.jar # TODO: make API jar names consistent with release jars, then simplify away this step
tag: ${{ needs.release-please.outputs.tag_name }}
overwrite: true
file_glob: true
clean: # TODO: run this conditionally per #22
name: Clean up
needs:
- run
- release
runs-on: ubuntu-22.04
steps:
- name: Delete artifacts
uses: geekyeggo/[email protected]
with:
name: |
jars-*
failOnError: false