forked from etlegacy/etlegacy
-
Notifications
You must be signed in to change notification settings - Fork 0
370 lines (318 loc) · 12 KB
/
ci.yml
File metadata and controls
370 lines (318 loc) · 12 KB
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
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
# ______ _______ _
#| ____| |__ __| | |
#| |__ | | | | ___ __ _ __ _ ___ _ _
#| __| | | | | / _ \ / _` | / _` | / __| | | | |
#| |____ | | | |____ | __/ | (_| | | (_| | | (__ | |_| |
#|______| |_| |______| \___| \__, | \__,_| \___| \__, |
# __/ | __/ |
# |___/ |___/
name: CI
on:
pull_request:
branches: [main, master]
types: [opened, synchronize, reopened]
push:
branches: [main, master]
# cancel previous unfinished/running jobs in each separate branch
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
pre-build:
runs-on: ubuntu-latest
outputs:
describe: ${{ steps.git.outputs.describe }}
tag: ${{ steps.git.outputs.tag }}
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
fetch-depth: 0
fetch-tags: true
- uses: prefix-dev/setup-pixi@92815284c57faa15cd896c4d5cfb2d59f32dc43d # v0.8.3
with:
pixi-version: v0.41.4
cache: true
- name: Check changes
run: |
pixi run check-changes --github "origin/main"
- name: Fetch git version information
id: git
run: |
git fetch --tags --force
git_describe=$(git describe --abbrev=7 2>/dev/null | awk '{$1=$1};1')
git_tag=$(git describe --abbrev=0 2>/dev/null | awk '{$1=$1};1')
echo "Version info: $git_describe ?? $git_tag"
echo "describe=$git_describe" >> "$GITHUB_OUTPUT"
echo "tag=$git_tag" >> "$GITHUB_OUTPUT"
# Run the build on all the current platforms
#
# etlegacy/lnx-build:latest ships an older glibc, so JS-based actions (like actions/checkout)
# cannot run inside the job container (node20 fails to start).
#
# Therefore these jobs use a pure `git` checkout step instead of `uses: actions/checkout`.
lnx64:
runs-on: ubuntu-24.04
needs: [pre-build]
container:
image: etlegacy/lnx-build:latest
options: --user 1001:1001
env:
CI_ETL_DESCRIBE: ${{ needs.pre-build.outputs.describe }}
CI_ETL_TAG: ${{ needs.pre-build.outputs.tag }}
CI: "true"
GITHUB_TOKEN: ${{ github.token }}
steps:
- name: Checkout (git, no JS actions)
shell: bash
run: |
set -euo pipefail
git config --global --add safe.directory "$GITHUB_WORKSPACE"
# Make submodules work even if they use https://github.com/, git://github.com/, or ssh
git config --global url."https://x-access-token:${GITHUB_TOKEN}@github.com/".insteadOf "https://github.com/"
git config --global url."https://x-access-token:${GITHUB_TOKEN}@github.com/".insteadOf "git://github.com/"
git config --global url."https://x-access-token:${GITHUB_TOKEN}@github.com/".insteadOf "ssh://git@github.com/"
git config --global url."https://x-access-token:${GITHUB_TOKEN}@github.com/".insteadOf "git@github.com:"
# Ensure workspace is empty
mkdir -p "$GITHUB_WORKSPACE"
find "$GITHUB_WORKSPACE" -mindepth 1 -maxdepth 1 -exec rm -rf {} +
cd "$GITHUB_WORKSPACE"
git init
git remote add origin "https://github.com/${GITHUB_REPOSITORY}.git"
# Works for push (refs/heads/...) and PR (refs/pull/.../merge)
git fetch --no-tags --prune --depth=1 origin "${GITHUB_REF}"
git checkout --detach FETCH_HEAD
git submodule sync --recursive
git submodule update --init --recursive --depth 1 || git submodule update --init --recursive
- name: Build
run: |
./easybuild.sh build -64
- name: Generate packages
working-directory: build
run: cpack
lnx32:
runs-on: ubuntu-24.04
needs: [pre-build]
container:
image: etlegacy/lnx-build:latest
options: --user 1001:1001
env:
CI_ETL_DESCRIBE: ${{ needs.pre-build.outputs.describe }}
CI_ETL_TAG: ${{ needs.pre-build.outputs.tag }}
CI: "true"
GITHUB_TOKEN: ${{ github.token }}
steps:
- name: Checkout (git, no JS actions)
shell: bash
run: |
set -euo pipefail
git config --global --add safe.directory "$GITHUB_WORKSPACE"
# Make submodules work even if they use https://github.com/, git://github.com/, or ssh
git config --global url."https://x-access-token:${GITHUB_TOKEN}@github.com/".insteadOf "https://github.com/"
git config --global url."https://x-access-token:${GITHUB_TOKEN}@github.com/".insteadOf "git://github.com/"
git config --global url."https://x-access-token:${GITHUB_TOKEN}@github.com/".insteadOf "ssh://git@github.com/"
git config --global url."https://x-access-token:${GITHUB_TOKEN}@github.com/".insteadOf "git@github.com:"
# Ensure workspace is empty
mkdir -p "$GITHUB_WORKSPACE"
find "$GITHUB_WORKSPACE" -mindepth 1 -maxdepth 1 -exec rm -rf {} +
cd "$GITHUB_WORKSPACE"
git init
git remote add origin "https://github.com/${GITHUB_REPOSITORY}.git"
# Works for push (refs/heads/...) and PR (refs/pull/.../merge)
git fetch --no-tags --prune --depth=1 origin "${GITHUB_REF}"
git checkout --detach FETCH_HEAD
git submodule sync --recursive
git submodule update --init --recursive --depth 1 || git submodule update --init --recursive
- name: Build
run: |
./easybuild.sh build -32
- name: Generate packages
working-directory: build
run: cpack
lnx-aarch64:
runs-on: ubuntu-latest
needs: [pre-build]
container:
image: etlegacy/lnx-aarch64-build
env:
CI_ETL_DESCRIBE: ${{ needs.pre-build.outputs.describe }}
CI_ETL_TAG: ${{ needs.pre-build.outputs.tag }}
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
submodules: true
- name: Build
run: |
./easybuild.sh build -RPIT -ninja
- name: Generate packages
shell: bash
working-directory: build
run: cpack
osx:
runs-on: macos-14
needs: [pre-build]
env:
CI_ETL_DESCRIBE: ${{ needs.pre-build.outputs.describe }}
CI_ETL_TAG: ${{ needs.pre-build.outputs.tag }}
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
submodules: true
- name: Install dependencies
run: |
brew bundle
brew install freetype librsvg graphicsmagick imagemagick
- name: Build
env:
SDKROOT: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
DEVELOPER_DIR: /Library/Developer/CommandLineTools
shell: bash
run: |
./easybuild.sh build -64 --osx=10.10 --osx-arc="x86_64;arm64" -j
- name: Generate packages
shell: bash
run: ./easybuild.sh package -64 --osx=10.10 --osx-arc="x86_64;arm64" -j
win:
runs-on: windows-2022
needs: [pre-build]
env:
CI_ETL_DESCRIBE: ${{ needs.pre-build.outputs.describe }}
CI_ETL_TAG: ${{ needs.pre-build.outputs.tag }}
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
submodules: true
- name: Build
shell: cmd
run: |
call .\easybuild.bat build
- name: Generate packages
shell: cmd
working-directory: build
run: cpack
win64:
runs-on: windows-2022
needs: [pre-build]
env:
CI_ETL_DESCRIBE: ${{ needs.pre-build.outputs.describe }}
CI_ETL_TAG: ${{ needs.pre-build.outputs.tag }}
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
submodules: true
- name: Build
shell: cmd
run: |
call .\easybuild.bat build -64
- name: Generate packages
shell: cmd
working-directory: build
run: cpack
android:
runs-on: ubuntu-24.04
env:
CI_ETL_DESCRIBE: ${{ needs.pre-build.outputs.describe }}
CI_ETL_TAG: ${{ needs.pre-build.outputs.tag }}
# Stable native / APK outputs in CI logs
ANDROID_SDK_ROOT: /opt/android-sdk
GRADLE_OPTS: -Dorg.gradle.daemon=false -Dorg.gradle.workers.max=4 -Dkotlin.incremental=false
needs: [pre-build]
container:
image: etlegacy/android-build
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
submodules: true
fetch-depth: 0
fetch-tags: true
- name: Setup JDK
uses: actions/setup-java@c1e323688fd81a25caa38c78aa6df2d33d3e20d9 # v4
with:
distribution: "temurin"
# JDK 21+: Gradle 8.x must instrument deps with Java 21 bytecode (e.g. BouncyCastle 1.79)
java-version: "21"
cache: "gradle"
cache-dependency-path: |
**/*.gradle*
app/libs/joystick/**/*.gradle*
- name: Build JoyStick Dependency
working-directory: ./app/libs/joystick
run: |
./gradlew --no-daemon clean --stacktrace --warning-mode all
./gradlew --no-daemon assembleRelease --stacktrace --warning-mode all
./gradlew --no-daemon publishToMavenLocal --stacktrace --warning-mode all
- name: Lint and unit tests (app)
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
./gradlew --no-daemon lintDebug testDebugUnitTest --stacktrace --warning-mode all
- name: Build and Generate Package
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
./gradlew --no-daemon clean assembleDebug --stacktrace --warning-mode all
ls -R
- name: Rename APK
run: |
shopt -s nullglob
for FILE in ./app/build/outputs/apk/debug/*.apk; do mv "$FILE" "${FILE%-*}.apk"; done
ls app/build/outputs/apk/debug
check-compiler-warnings:
runs-on: ubuntu-latest
needs:
- android
- lnx-aarch64
- lnx32
- lnx64
- osx
- win
- win64
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
fetch-depth: 0
fetch-tags: true
- uses: prefix-dev/setup-pixi@92815284c57faa15cd896c4d5cfb2d59f32dc43d # v0.8.3
with:
pixi-version: v0.41.4
cache: true
- name: Collect and Check GitHub Build Logs
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # fallback
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_RUN_ID: ${{ github.run_id }}
run: |
pixi run collect-and-check-gh-build-logs --github
ci-discord-notify-on-failure:
needs:
- pre-build
- android
- lnx-aarch64
- lnx32
- lnx64
- osx
- win
- win64
- check-compiler-warnings
if: |
github.event_name == 'push' &&
(github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') &&
failure()
runs-on: ubuntu-latest
steps:
- name: Notify Discord
env:
DISCORD_WEBHOOK: ${{ secrets.LEGACY_CI_WEBHOOK }}
COMMIT_SHA: ${{ github.sha }}
REPO: ${{ github.repository }}
RUN_ID: ${{ github.run_id }}
DEVS_ROLE_ID: "260752921698762752"
run: |
if [ -z "${DISCORD_WEBHOOK:-}" ]; then
echo "DISCORD_WEBHOOK unset; skipping Discord notification."
exit 0
fi
RUN_URL="https://github.com/${REPO}/actions/runs/${RUN_ID}"
MESSAGE="❌ **[failed on commit](<${RUN_URL}>)** \`${COMMIT_SHA}\` <@&${DEVS_ROLE_ID}>"
curl -H "Content-Type: application/json" \
-X POST \
-d "{\"content\": \"$MESSAGE\", \"allowed_mentions\": {\"roles\": [\"$DEVS_ROLE_ID\"]}}" \
"$DISCORD_WEBHOOK"