-
Notifications
You must be signed in to change notification settings - Fork 4
381 lines (329 loc) · 13 KB
/
Copy pathmain.yml
File metadata and controls
381 lines (329 loc) · 13 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
371
372
373
374
375
376
377
378
379
380
381
# 🌿 We aim to reduce the usage footprint of GitHub Actions by caching dependencies,
# optimizing build processes, and cleaning up stale artifacts.
# Efficiency is not just about speed — it's also about responsible use
# of cloud computing resources and reducing unnecessary energy consumption.
#
# — Polina "Aura" N. and Julia Nechaevskaya
name: Build Windows and Linux
on:
push:
branches:
- main
pull_request:
branches:
- main
schedule:
- cron: "0 3 * * *" # Nightly build at 03:00 UTC
permissions:
contents: write
actions: write
env:
VCPKG_BINARY_SOURCES: "clear;files,${{ github.workspace }}/vcpkg_cache,readwrite"
jobs:
windows_64bit:
name: Windows (64-bit)
runs-on: windows-2025-vs2026
steps:
- name: Check out repository
uses: actions/checkout@v7
- name: Cache vcpkg installed packages and archive
uses: actions/cache/restore@v6
with:
path: ${{ github.workspace }}/vcpkg_cache
key: vcpkg-windows-${{ hashFiles('vcpkg.json') }}
- name: Prepare vcpkg
shell: bash
run: |
if [ ! -f "vcpkg/bootstrap-vcpkg.bat" ]; then
rm -rf vcpkg
git clone https://github.com/microsoft/vcpkg.git
fi
./vcpkg/bootstrap-vcpkg.bat
- name: Install dependencies and configure CMake
run: |
.\vcpkg\vcpkg.exe install `
--triplet x64-windows-static-release `
--overlay-triplets=cmake/triplets
cmake -B build_vs_64 -S . -DCMAKE_BUILD_TYPE=Release `
-DENABLE_LTO=ON `
-DVCPKG_TARGET_TRIPLET="x64-windows-static-release" `
-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded `
-DCMAKE_C_FLAGS_RELEASE="/MT /O2 /Ob2 /DNDEBUG /GL /Oy" `
-DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}\vcpkg\scripts\buildsystems\vcpkg.cmake
- name: Build
run: cmake --build build_vs_64 --config Release --parallel
# Delete the old cache on hit to emulate a cache update.
- name: Delete old cache
continue-on-error: true
run: gh cache delete --repo ${{ github.repository }} ${{ env.CACHE_KEY }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CACHE_KEY: vcpkg-windows-${{ hashFiles('vcpkg.json') }}
- name: Save new cache
uses: actions/cache/save@v6
env:
CACHE_KEY: vcpkg-windows-${{ hashFiles('vcpkg.json') }}
with:
path: ${{ github.workspace }}/vcpkg_cache
key: ${{ env.CACHE_KEY }}
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: crl-win64
path: build_vs_64/src/Release/*.exe
retention-days: 3
windows_32bit:
name: Windows (32-bit)
runs-on: windows-2025-vs2026
steps:
- name: Check out repository
uses: actions/checkout@v7
- name: Install Visual Studio 2019 Build Tools with v141_xp
run: |
choco install visualstudio2019buildtools --package-parameters "
--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64
--add Microsoft.Component.VC.Runtime.UCRTSDK
--add Microsoft.VisualStudio.Component.WinXP
--add Microsoft.VisualStudio.Component.VC.v141.x86.x64
--includeRecommended --includeOptional" -y
- name: Configure CMake (XP target)
shell: cmd
run: |
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" x86
cmake -B build_vs_32 ^
-G "Visual Studio 16 2019" ^
-T v141_xp ^
-A Win32 ^
-DCMAKE_BUILD_TYPE="Release" ^
-DSDL2_DIR="lib/win32/SDL2-2.32.10" ^
-DSDL2_MIXER_DIR="lib/win32/SDL2_mixer-2.8.2" ^
-DCMAKE_FIND_PACKAGE_PREFER_CONFIG=Off ^
-DSAMPLERATE_DIR="lib/win32/libsamplerate-0.2.2-win32" ^
-DCMAKE_PREFIX_PATH="lib/win32/fluidsynth-2.4.2-winXP-x86"
- name: Build
run: cmake --build build_vs_32 --config Release --parallel -- /p:XPDeprecationWarning=false
- name: Prepare binaries for packaging
run: |
mkdir upload
copy build_vs_32/src/Release/*.exe upload
copy lib/win32/dlls-vc-win32/*.dll upload
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: crl-win32
path: upload/*
retention-days: 3
linux_64bit:
name: Linux AppImage (64-bit)
runs-on: ubuntu-22.04
steps:
- name: Check out repository
uses: actions/checkout@v7
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y cmake g++ fuse patchelf \
libsdl2-dev libsdl2-mixer-dev \
libsamplerate0-dev libfluidsynth-dev fluidsynth \
libflac-dev libmodplug-dev libmpg123-dev libopusfile-dev \
libx11-dev libxext-dev libxrender-dev libxrandr-dev \
libxcb1-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev
- name: Install linuxdeploy and plugin
run: |
wget -q https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
wget -q https://github.com/linuxdeploy/linuxdeploy-plugin-appimage/releases/download/continuous/linuxdeploy-plugin-appimage-x86_64.AppImage
chmod +x linuxdeploy*.AppImage
- name: Build the project
run: |
cmake -B build_linux -S . -DCMAKE_BUILD_TYPE=Release \
-D CMAKE_C_FLAGS_RELEASE="-O3 -march=x86-64-v2 -mtune=generic -flto -fno-math-errno -fomit-frame-pointer -funroll-loops -DNDEBUG"
cmake --build build_linux --config Release
- name: Prepare AppDir for Doom
run: |
mkdir -p appdir-doom/usr/bin
cp build_linux/src/crl-doom appdir-doom/usr/bin/
mkdir -p appdir-doom/usr/share/applications
cp data/doom.desktop appdir-doom/usr/share/applications/crl-doom.desktop
mkdir -p appdir-doom/usr/share/icons/hicolor/128x128/apps
cp data/doom.png appdir-doom/usr/share/icons/hicolor/128x128/apps/crl-doom.png
- name: Package Doom as AppImage
run: |
LDAI_OUTPUT=crl-doom-x86_64.AppImage \
LDAI_UPDATE_INFORMATION="gh-releases-zsync|JNechaevsky|CRL|latest|crl-doom-x86_64.AppImage.zsync" \
./linuxdeploy-x86_64.AppImage --appdir=appdir-doom --output appimage
- name: Prepare AppDir for Heretic
run: |
mkdir -p appdir-heretic/usr/bin
cp build_linux/src/crl-heretic appdir-heretic/usr/bin/
mkdir -p appdir-heretic/usr/share/applications
cp data/heretic.desktop appdir-heretic/usr/share/applications/crl-heretic.desktop
mkdir -p appdir-heretic/usr/share/icons/hicolor/128x128/apps
cp data/heretic.png appdir-heretic/usr/share/icons/hicolor/128x128/apps/crl-heretic.png
- name: Package Heretic as AppImage
run: |
./linuxdeploy-x86_64.AppImage --appdir=appdir-heretic --output appimage
- name: Clean up unnecessary files
run: |
rm -f linuxdeploy*.AppImage
- name: Bundle AppImages
run: |
mkdir bundled_appimages
cp crl-*-x86_64.AppImage* bundled_appimages/
- name: Upload all AppImages bundle
uses: actions/upload-artifact@v7
with:
name: crl-linux64
path: bundled_appimages/*
retention-days: 3
codeql:
name: Analyze (CodeQL)
runs-on: ubuntu-latest
permissions:
security-events: write
steps:
- uses: actions/checkout@v7
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install fluidsynth libfluidsynth-dev libsamplerate0-dev libsdl2-dev libsdl2-mixer-dev ninja-build
- name: Configure CMake
run: cmake -S . -B debug -G Ninja -DCMAKE_BUILD_TYPE=Debug
- name: Initialize CodeQL
uses: github/codeql-action/init@v4.37.6
with:
languages: c-cpp
build-mode: manual
- name: Build the project (CodeQL will trace it)
run: |
cmake --build debug --parallel
env:
CC: clang
CXX: clang++
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v4.37.6
with:
category: "/language:c-cpp"
cppcheck:
name: Analyze (Cppcheck)
runs-on: ubuntu-latest
steps:
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install cppcheck
- uses: actions/checkout@v7
- name: Run cppcheck
env:
ANALYZE: true
run: |
cppcheck --error-exitcode=1 -j2 -UTESTING -D__GNUC__ -Iopl -Isrc -Isrc/setup opl pcsound src textscreen
cpp-linter:
name: Analyze (Cpp-linter)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install fluidsynth libfluidsynth-dev libsamplerate0-dev libsdl2-dev libsdl2-mixer-dev ninja-build
- name: Run cmake to generate compilation database
run: cmake -S . -B . -G Ninja -DCMAKE_EXPORT_COMPILE_COMMANDS=1
- uses: cpp-linter/cpp-linter-action@v2
id: linter
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
style: '' # Disable clang-format
lines-changed-only: true
files-changed-only: true
tidy-checks: >-
boost-*
,bugprone-*
,performance-*
,readability-*
,portability-*
,modernize-*
,clang-analyzer-*
,cppcoreguidelines-*
,-cppcoreguidelines-avoid-magic-numbers
,-cppcoreguidelines-init-variables
,-readability-identifier-length
,-readability-isolate-declaration
,-readability-magic-numbers
- name: Fail if linting issues found
if: steps.linter.outputs.checks-failed > 0
run: |
echo "Some files failed the linting checks! Fail fast disabled until false positive issue is fixed"
# exit 1
- name: Verify that 'extern' is not used in .c files
run: |
# Find all .c files (excluding lib/miniz) and grep for 'extern'
EXTERN=$(find . -name "*.c" -not -path "./lib/miniz/*" -exec grep -H -e 'extern[^A-Za-z0-9_]' {} \;)
if [ -n "$EXTERN" ]; then
echo "❌ 'extern' found in .c files (should only be in .h files):"
echo "$EXTERN"
# exit 1
else
echo "✅ No 'extern' declarations found in .c files"
fi
release_nightly:
name: Create Nightly Release
runs-on: ubuntu-latest
needs: [windows_64bit, windows_32bit, linux_64bit]
if: github.event_name == 'schedule'
steps:
- name: Download Windows 64-bit artifact
uses: actions/download-artifact@v8
with:
name: crl-win64
path: ./artifacts/win64
- name: Download Windows 32-bit artifact
uses: actions/download-artifact@v8
with:
name: crl-win32
path: ./artifacts/win32
- name: Download Linux 64-bit artifact
uses: actions/download-artifact@v8
with:
name: crl-linux64
path: ./artifacts/linux64
- name: Archive Windows 64-bit artifacts
run: |
zip -j -r ./artifacts/crl-win64.zip ./artifacts/win64/*
- name: Archive Windows 32-bit artifacts
run: |
zip -j -r ./artifacts/crl-win32.zip ./artifacts/win32/*
- name: Create/Update Nightly release with artifacts
if: github.event_name != 'pull_request'
uses: softprops/action-gh-release@v3
with:
tag_name: nightly
name: Nightly Release
prerelease: true
draft: false
files: |
./artifacts/crl-win64.zip
./artifacts/crl-win32.zip
./artifacts/linux64/*.AppImage
./artifacts/linux64/*.AppImage.zsync
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
cleanup_actions:
name: Cleanup Actions
runs-on: ubuntu-latest
needs: [windows_64bit, windows_32bit, linux_64bit]
if: always() && github.event_name != 'pull_request'
steps:
- name: Keep only latest workflow runs
env:
GH_TOKEN: ${{ github.token }}
KEEP_RUNS: 3
run: |
gh api --paginate \
/repos/${GITHUB_REPOSITORY}/actions/runs \
--jq ".workflow_runs[]
| select(.status == \"completed\")
| select((.id | tostring) != \"${GITHUB_RUN_ID}\")
| [.created_at, .id]
| @tsv" \
| sort -r \
| tail -n +$((KEEP_RUNS + 1)) \
| cut -f2 \
| while read -r run_id; do
echo "Deleting workflow run ${run_id}"
gh api -X DELETE /repos/${GITHUB_REPOSITORY}/actions/runs/${run_id}
done