forked from ammaarreshi/Generals-Mac-iOS-iPad
-
Notifications
You must be signed in to change notification settings - Fork 1
339 lines (307 loc) · 12.5 KB
/
Copy pathbuild-linux.yml
File metadata and controls
339 lines (307 loc) · 12.5 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
name: Build Linux
permissions:
contents: read
pull-requests: write
on:
workflow_call:
inputs:
preset:
required: false
type: string
default: "linux64-deploy"
description: "CMake preset for Linux"
package_format:
required: false
type: string
default: "gzip"
description: "Artifact packaging format: gzip or appimage"
workflow_dispatch:
inputs:
preset:
type: choice
description: "CMake preset for Linux"
options:
- linux64-deploy
- linux64-testing
default: linux64-deploy
package_format:
type: choice
description: "Artifact packaging format"
options:
- gzip
- appimage
default: gzip
jobs:
build-linux:
name: ${{ matrix.game.id }}@${{ inputs.preset }}
runs-on: ubuntu-latest
timeout-minutes: 120
strategy:
fail-fast: false
matrix:
game:
- id: generalsxzh
value: GeneralsMD
target: z_generals
output: GeneralsXZH
log_suffix: zh
- id: generalsx
value: Generals
target: g_generals
output: GeneralsX
log_suffix: generals
package_format:
- ${{ inputs.package_format }}
steps:
# GeneralsX @build GitHubCopilot 08/05/2026 Use Node 24 compatible GitHub Actions major versions to remove runner deprecation warnings.
- name: Checkout Code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Cache vcpkg
id: cache-vcpkg
uses: actions/cache@v5
with:
path: /opt/vcpkg
key: vcpkg-linux-${{ runner.os }}-${{ hashFiles('vcpkg.json', 'vcpkg-lock.json') }}
restore-keys: |
vcpkg-linux-${{ runner.os }}-
- name: Install Dependencies
run: |
echo "Installing Linux build dependencies (matching Dockerfile.linux)..."
sudo apt-get update -qq
sudo apt-get install -y -qq --no-install-recommends \
build-essential \
cmake \
ninja-build \
git \
curl \
ca-certificates \
zip \
unzip \
tar \
pkg-config \
python3 \
python3-pip \
python3-dev \
autoconf \
automake \
autoconf-archive \
libtool \
libltdl-dev \
libopenal-dev \
libasound2-dev \
libpulse-dev \
libaudio-dev \
libavcodec-dev \
libavformat-dev \
libavutil-dev \
libswresample-dev \
libswscale-dev \
libpng-dev \
zlib1g-dev \
libfribidi-dev \
libjack-dev \
libsndio-dev \
libx11-dev \
libxext-dev \
libxrandr-dev \
libxcursor-dev \
libxfixes-dev \
libxi-dev \
libxss-dev \
libxtst-dev \
libxkbcommon-dev \
libdrm-dev \
libgbm-dev \
libgl1-mesa-dev \
libgles2-mesa-dev \
libegl1-mesa-dev \
libdbus-1-dev \
libibus-1.0-dev \
libudev-dev \
libthai-dev \
libpipewire-0.3-dev \
libwayland-dev \
libdecor-0-dev \
liburing-dev \
libvulkan-dev
echo "Dependencies installed."
cmake --version
ninja --version
- name: Bootstrap vcpkg
run: |
echo "Bootstrapping vcpkg..."
mkdir -p /opt/vcpkg
# Check if vcpkg already cached
if [ ! -f /opt/vcpkg/vcpkg ]; then
echo "Cloning vcpkg from GitHub..."
git clone https://github.com/microsoft/vcpkg.git /opt/vcpkg
git -C /opt/vcpkg checkout ffc071e0c08432c60c9b64f00334c0227667931b
echo "Running vcpkg bootstrap..."
/opt/vcpkg/bootstrap-vcpkg.sh -disableMetrics
else
echo "Using cached vcpkg"
fi
export VCPKG_ROOT=/opt/vcpkg
echo "VCPKG_ROOT=/opt/vcpkg" >> $GITHUB_ENV
echo "✅ vcpkg ready at: /opt/vcpkg"
- name: Configure CMake (Linux)
run: |
mkdir -p logs
cmake --preset ${{ inputs.preset }} 2>&1 | tee logs/configure_linux.log
echo "CMake configuration complete."
- name: Build ${{ matrix.game.value }}
run: |
mkdir -p logs
cmake --build build/${{ inputs.preset }} --target ${{ matrix.game.target }} 2>&1 | tee logs/build_${{ matrix.game.log_suffix }}_linux.log
echo "Build complete."
- name: Verify Build Artifacts
run: |
BINARY="build/${{ inputs.preset }}/${{ matrix.game.value }}/${{ matrix.game.output }}"
if [ -f "$BINARY" ]; then
echo "✅ Binary built: ${{ matrix.game.output }} ($BINARY)"
file "$BINARY"
ls -lh "$BINARY"
else
echo "❌ Binary NOT found: $BINARY"
exit 1
fi
# GeneralsX @build GitHubCopilot 10/04/2026 Package as AppImage (self-contained, no FUSE needed for appimagetool in CI via APPIMAGE_EXTRACT_AND_RUN).
- name: Package as AppImage
if: success() && matrix.package_format == 'appimage'
env:
APPIMAGE_EXTRACT_AND_RUN: "1"
run: |
if [ "${{ matrix.game.value }}" = "GeneralsMD" ]; then
./scripts/build/linux/build-linux-appimage-zh.sh ${{ inputs.preset }}
else
./scripts/build/linux/build-linux-appimage-generals.sh ${{ inputs.preset }}
fi
# GeneralsX @build GitHubCopilot 10/04/2026 Legacy gzip bundle kept as opt-in fallback for CI/testing.
- name: Package as gzip bundle
if: success() && matrix.package_format == 'gzip'
run: |
BINARY="build/${{ inputs.preset }}/${{ matrix.game.value }}/${{ matrix.game.output }}"
RUNTIME_DIR="/tmp/GeneralsX-${{ matrix.game.value }}-deploy"
FFMPEG_LIB_DIR="/usr/lib/x86_64-linux-gnu"
FFMPEG_DEP_LIB_DIR="/lib/x86_64-linux-gnu"
mkdir -p "${RUNTIME_DIR}"
copy_ldd_deps() {
local root="$1"
[[ -e "${root}" ]] || return 0
while IFS= read -r dep; do
case "${dep}" in
linux-vdso.so.1 | \
/lib64/ld-linux* | /lib/*/ld-linux* | /usr/lib/*/ld-linux* | /usr/lib64/ld-linux* | \
/lib/*/libc.so.* | /lib64/libc.so.* | /usr/lib/*/libc.so.* | /usr/lib64/libc.so.* | \
/lib/*/libm.so.* | /lib64/libm.so.* | /usr/lib/*/libm.so.* | /usr/lib64/libm.so.* | \
/lib/*/libpthread.so.* | /lib64/libpthread.so.* | /usr/lib/*/libpthread.so.* | /usr/lib64/libpthread.so.* | \
/lib/*/librt.so.* | /lib64/librt.so.* | /usr/lib/*/librt.so.* | /usr/lib64/librt.so.* | \
/lib/*/libdl.so.* | /lib64/libdl.so.* | /usr/lib/*/libdl.so.* | /usr/lib64/libdl.so.*)
continue
;;
esac
cp -a "${dep}" "${RUNTIME_DIR}/" 2>/dev/null || true
if [[ -L "${dep}" ]]; then
local resolved
resolved="$(readlink -f "${dep}")"
cp -a "${resolved}" "${RUNTIME_DIR}/" 2>/dev/null || true
fi
done < <(ldd "${root}" | awk '{for (i = 1; i <= NF; ++i) { if ($i ~ /^\//) { print $i; break } }}' | sort -u)
}
echo "Creating deployment bundle at: ${RUNTIME_DIR}"
echo " Copying executable..."
cp -v "${BINARY}" "${RUNTIME_DIR}/$(basename ${BINARY})"
chmod +x "${RUNTIME_DIR}/$(basename ${BINARY})"
echo " Copying DXVK libraries..."
find "build/${{ inputs.preset }}/_deps/dxvk-src/lib" -name "*.so*" -exec cp -v {} "${RUNTIME_DIR}/" \; 2>/dev/null || true
echo " Copying SDL3 libraries..."
find "build/${{ inputs.preset }}/_deps/sdl3-build" -name "*.so*" -exec cp -v {} "${RUNTIME_DIR}/" \; 2>/dev/null || true
find "build/${{ inputs.preset }}/_deps/sdl3_image-build" -name "*.so*" -exec cp -v {} "${RUNTIME_DIR}/" \; 2>/dev/null || true
echo " Copying OpenAL library..."
find "build/${{ inputs.preset }}/_deps/openal_soft-build" -name "*.so*" -exec cp -v {} "${RUNTIME_DIR}/" \; 2>/dev/null || true
# GeneralsX @build GitHubCopilot 17/05/2026 Bundle FFmpeg runtime libs transitively so replay CI does not depend on host SONAME layout.
echo " Copying FFmpeg runtime libraries..."
shopt -s nullglob
ffmpeg_roots=(
"${FFMPEG_LIB_DIR}"/libavcodec.so*
"${FFMPEG_LIB_DIR}"/libavformat.so*
"${FFMPEG_LIB_DIR}"/libavutil.so*
"${FFMPEG_LIB_DIR}"/libswresample.so*
"${FFMPEG_LIB_DIR}"/libswscale.so*
"${FFMPEG_DEP_LIB_DIR}"/libavcodec.so*
"${FFMPEG_DEP_LIB_DIR}"/libavformat.so*
"${FFMPEG_DEP_LIB_DIR}"/libavutil.so*
"${FFMPEG_DEP_LIB_DIR}"/libswresample.so*
"${FFMPEG_DEP_LIB_DIR}"/libswscale.so*
)
shopt -u nullglob
for ffmpeg_root in "${ffmpeg_roots[@]}"; do
cp -a "${ffmpeg_root}" "${RUNTIME_DIR}/" 2>/dev/null || true
copy_ldd_deps "${ffmpeg_root}"
done
echo " Copying GameSpy library..."
find "build/${{ inputs.preset }}" -name "libgamespy.so*" -exec cp -v {} "${RUNTIME_DIR}/" \; 2>/dev/null || true
echo " Copying run.sh wrapper from scripts..."
cp -v "scripts/qa/smoke/run-bundled-game.sh" "${RUNTIME_DIR}/run.sh"
chmod +x "${RUNTIME_DIR}/run.sh"
if ! compgen -G "${RUNTIME_DIR}/libgamespy.so*" > /dev/null; then
echo "ERROR: Missing required runtime library: libgamespy.so*"
exit 1
fi
if ! compgen -G "${RUNTIME_DIR}/libdxvk_d3d8.so*" > /dev/null; then
echo "ERROR: Missing required runtime library: libdxvk_d3d8.so*"
exit 1
fi
if ! compgen -G "${RUNTIME_DIR}/libSDL3.so*" > /dev/null; then
echo "ERROR: Missing required runtime library: libSDL3.so*"
exit 1
fi
if ! compgen -G "${RUNTIME_DIR}/libopenal.so*" > /dev/null; then
echo "ERROR: Missing required runtime library: libopenal.so*"
exit 1
fi
if ! compgen -G "${RUNTIME_DIR}/libavcodec.so*" > /dev/null; then
echo "ERROR: Missing required runtime library: libavcodec.so*"
exit 1
fi
echo "Bundle ready at: ${RUNTIME_DIR}"
ls -lh "${RUNTIME_DIR}/"
BUNDLE_TAR="/tmp/GeneralsX-${{ matrix.game.value }}-${{ inputs.preset }}.tar"
tar -C "/tmp" -cf "${BUNDLE_TAR}" "GeneralsX-${{ matrix.game.value }}-deploy/"
echo "Archive ready: ${BUNDLE_TAR}"
- name: Set artifact metadata
id: artifact
if: success()
run: |
PRESET="${{ inputs.preset }}"
FORMAT="${{ matrix.package_format }}"
GAME_SLUG="${{ matrix.game.id }}"
PRESET_SLUG="${{ inputs.preset == 'linux64-deploy' && 'linux64' || inputs.preset }}"
if [ "${FORMAT}" = "gzip" ]; then
echo "name=linux-${GAME_SLUG}-${PRESET_SLUG}-bundle" >> "$GITHUB_OUTPUT"
echo "path=/tmp/GeneralsX-${{ matrix.game.value }}-${PRESET}.tar" >> "$GITHUB_OUTPUT"
else
INPUT_PATH="build/${{ matrix.game.output }}-${PRESET}-x86_64.AppImage"
OUTPUT_PATH="/tmp/${{ matrix.game.output }}-${PRESET}-x86_64.AppImage"
# GeneralsX @bugfix GitHubCopilot 10/04/2026 Flatten uploaded AppImage artifact structure (no intermediate directories inside zip).
cp -f "${INPUT_PATH}" "${OUTPUT_PATH}"
echo "name=linux-${GAME_SLUG}-${PRESET_SLUG}-appimage" >> "$GITHUB_OUTPUT"
echo "path=${OUTPUT_PATH}" >> "$GITHUB_OUTPUT"
fi
- name: Upload Build Logs
if: always()
uses: actions/upload-artifact@v7
with:
name: build-logs-linux-${{ matrix.game.id }}-${{ matrix.package_format }}
path: logs/
retention-days: 7
- name: Upload Deployment Bundle
if: success()
uses: actions/upload-artifact@v7
with:
name: ${{ steps.artifact.outputs.name }}
path: ${{ steps.artifact.outputs.path }}
retention-days: 7
if-no-files-found: warn