-
Notifications
You must be signed in to change notification settings - Fork 16
480 lines (414 loc) · 17.3 KB
/
Copy pathrelease.yml
File metadata and controls
480 lines (414 loc) · 17.3 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
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
name: Release
on:
push:
tags:
- '*'
permissions:
contents: write
env:
SOLUTION_FILE_PATH: .
jobs:
# ─────────────────────────────────────────────
# Windows – MSBuild (x64 + x86)
# ─────────────────────────────────────────────
build-windows:
name: Windows (${{ matrix.BUILD_PLATFORM }})
runs-on: windows-latest
timeout-minutes: 60
strategy:
matrix:
BUILD_PLATFORM: [x86, x64]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@v2
- name: Setup vcpkg and install googletest
working-directory: ${{env.GITHUB_WORKSPACE}}
run: |
if (-not (Test-Path 'vcpkg')) {
git clone https://github.com/microsoft/vcpkg.git vcpkg
}
& .\vcpkg\bootstrap-vcpkg.bat
& .\vcpkg\vcpkg.exe install gtest:x86-windows gtest:x64-windows
& .\vcpkg\vcpkg.exe integrate install
- name: Restore NuGet packages
working-directory: ${{ github.workspace }}
run: nuget restore remc2.sln
- name: Set version
shell: bash
run: |
# Replace version
sed -i "s/Beta/$GITHUB_REF_NAME/g" remc2/engine/globals.h
cat remc2/engine/globals.h
if grep -q "$GITHUB_REF_NAME" remc2/engine/globals.h; then
echo "Set Version Passed!"
else
echo "Set Version Failed!"
exit 1
fi
- name: Build Release
working-directory: ${{ github.workspace }}
run: |
msbuild /m `
/p:Configuration=Release `
/p:PlatformTarget=${{ matrix.BUILD_PLATFORM }} `
/p:Platform=${{ matrix.BUILD_PLATFORM }} `
/p:WarningLevel=0 `
${{ env.SOLUTION_FILE_PATH }}/remc2.sln
- name: Package (zip) - x86
if: matrix.BUILD_PLATFORM == 'x86'
shell: pwsh
run: |
Copy-Item "Install Guide.txt" "Release/"
Push-Location "Release"
7z a "../remc2-win-x86.zip" * -r
Pop-Location
- name: Package (zip) - x64
if: matrix.BUILD_PLATFORM == 'x64'
shell: pwsh
run: |
Copy-Item "Install Guide.txt" "x64/Release/"
Push-Location "x64/Release"
7z a "../../remc2-win-x64.zip" * -r
Pop-Location
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: remc2-win-${{ matrix.BUILD_PLATFORM }}
path: remc2-win-${{ matrix.BUILD_PLATFORM }}.zip
# ─────────────────────────────────────────────
# Windows – MSI installer (x64 + x86)
# ─────────────────────────────────────────────
build-installer:
name: Installer (${{ matrix.arch }})
runs-on: windows-latest
needs: build-windows
strategy:
matrix:
include:
- arch: x64
- arch: x86
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # FIX #6: added for consistent tag access
submodules: recursive
- name: Extract version
shell: bash
run: |
if [[ "$GITHUB_REF_NAME" =~ ([0-9]+(\.[0-9]+)+) ]]; then
echo "VERSION=${BASH_REMATCH[1]}" >> $GITHUB_ENV
else
echo "No version found in ref_name: $GITHUB_REF_NAME"
exit 1
fi
- name: Split version
shell: bash
run: |
IFS='.' read -r MAJOR MINOR REVISION BUILD <<< "$VERSION"
echo "MAJOR=$MAJOR" >> "$GITHUB_ENV"
echo "MINOR=$MINOR" >> "$GITHUB_ENV"
echo "REVISION=$REVISION" >> "$GITHUB_ENV"
echo "BUILD=${BUILD:-0}" >> "$GITHUB_ENV"
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.x'
- name: Install WiX Toolset v4
run: |
dotnet tool install --global wix --version 4.0.5
wix extension add -g WixToolset.Util.wixext/4.0.5
wix extension add -g WixToolset.UI.wixext/4.0.5
- name: Download win-${{ matrix.arch }} artifact
uses: actions/download-artifact@v4
with:
name: remc2-win-${{ matrix.arch }}
path: artifacts
- name: Prepare folders
shell: pwsh
run: |
$arch = "${{ matrix.arch }}"
# Unzip the zip
7z x "artifacts/remc2-win-$arch.zip" -o"unzipped" -y
# Detect structure - does the zip contain files directly or in a folder?
$items = Get-ChildItem "unzipped"
$src = if ($items.Count -eq 1 -and $items[0].PSIsContainer) { $items[0].FullName } else { (Resolve-Path "unzipped").Path }
# Copy the binaries to the location where Program.cs expects the exe+DLL
if ($arch -eq "x64") {
New-Item -ItemType Directory -Path "x64\Release" -Force | Out-Null
Get-ChildItem $src | Copy-Item -Destination "x64\Release" -Recurse -Force
} else {
New-Item -ItemType Directory -Path "Release" -Force | Out-Null
Get-ChildItem $src | Copy-Item -Destination "Release" -Recurse -Force
}
# kiss/ and font/ ALWAYS to Release/ - Program.cs has it hardcoded for both arch
New-Item -ItemType Directory -Path "Release\kiss" -Force | Out-Null
New-Item -ItemType Directory -Path "Release\font" -Force | Out-Null
Copy-Item "remc2-editor\kiss\*" "Release\kiss\" -Recurse -Force
Copy-Item "remc2\font\*" "Release\font\" -Recurse -Force
Copy-Item "remc2-editor\editor-config.json" "Release\" -Force -ErrorAction SilentlyContinue
# Replace version
(Get-Content remc2-installer\Program.cs).Replace('Version(0, 0, 0, 0)', "Version($env:MAJOR, $env:MINOR, $env:REVISION, $env:BUILD)") | Set-Content remc2-installer\Program.cs
# Verification
Write-Host "=== Release/ ==="; Get-ChildItem "Release" | Select Name
if ($arch -eq "x64") { Write-Host "=== x64/Release/ ==="; Get-ChildItem "x64\Release" | Select Name }
- name: Download VC Redist
shell: pwsh
run: |
$arch = "${{ matrix.arch }}"
New-Item -ItemType Directory -Path "remc2-installer/Extract" -Force | Out-Null
if ($arch -eq "x64") {
Invoke-WebRequest "https://aka.ms/vs/17/release/vc_redist.x64.exe" -OutFile "remc2-installer/Extract/VC_redist.x64.exe"
} else {
Invoke-WebRequest "https://aka.ms/vs/17/release/vc_redist.x86.exe" -OutFile "remc2-installer/Extract/VC_redist.x86.exe"
}
- name: Build installer
shell: pwsh
run: |
dotnet build remc2-installer.sln --configuration Release -p:Platform=${{ matrix.arch }} -p:AcceptEula=true || true
$msi = Get-ChildItem -Recurse -Filter "*.msi" | Select-Object -First 1
if (-not $msi) { Write-Error "Build failed - MSI not found!"; exit 1 }
Write-Host "MSI built: $($msi.FullName)"
- name: Locate and rename MSI
shell: pwsh
run: |
$msi = Get-ChildItem -Recurse -Filter "*.msi" | Select-Object -First 1
if (-not $msi) { Write-Error "MSI not found!"; exit 1 }
Copy-Item $msi.FullName "Magic.Carpet.2.HD.${{ matrix.arch }}.msi"
- name: Upload installer artifact
uses: actions/upload-artifact@v4
with:
name: installer-${{ matrix.arch }}
path: Magic.Carpet.2.HD.${{ matrix.arch }}.msi
# ─────────────────────────────────────────────
# Linux – x86_64
# ─────────────────────────────────────────────
build-linux:
name: Linux (x86_64)
runs-on: ubuntu-latest
env:
GITHUB_CI_COMPATIBILITY_PATH: /usr/lib/x86_64-linux-gnu
steps:
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get -y install --no-install-recommends \
cmake ninja-build \
libsdl2-dev libsdl2-mixer-dev \
libsdl2-ttf-dev libsdl2-image-dev \
libgtest-dev \
libspdlog-dev libfmt-dev \
nlohmann-json3-dev \
clang-tidy \
libwxgtk3.2-dev \
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
path: src
- name: Configure
run: |
mkdir -p build_Release
cd build_Release
cmake -GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DUSE_64_BIT=True \
-DGITHUB_CI_COMPATIBILITY_PATH="${{ env.GITHUB_CI_COMPATIBILITY_PATH }}" \
${{ github.workspace }}/src
- name: Build
run: |
cd build_Release
ninja
- name: Package (tar.gz)
run: |
mkdir -p remc2-linux-x86_64
find build_Release -maxdepth 3 -name "remc2" -type f -exec cp {} remc2-linux-x86_64/ \;
find build_Release -maxdepth 3 -name "remc2-editor" -type f -exec cp {} remc2-linux-x86_64/ \; || true
cp src/config.json remc2-linux-x86_64/
cp "src/Install Guide.txt" remc2-linux-x86_64/
cp src/check_install.sh remc2-linux-x86_64/
tar -czf remc2-linux-x86_64.tar.gz remc2-linux-x86_64/
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: remc2-linux-x86_64
path: remc2-linux-x86_64.tar.gz
# ─────────────────────────────────────────────
# Linux ARM64 (cross-compile)
# ─────────────────────────────────────────────
build-linux-arm64:
name: Linux (ARM64)
runs-on: ubuntu-latest
env:
GITHUB_CI_COMPATIBILITY_PATH: /usr/lib/aarch64-linux-gnu
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
path: src
- name: Install Dependencies (ARM64 cross)
run: |
sudo dpkg --add-architecture arm64
sudo grep -q "^Architectures:" /etc/apt/sources.list.d/ubuntu.sources || \
sudo sed -i 's/^Types: deb$/Types: deb\nArchitectures: amd64/' \
/etc/apt/sources.list.d/ubuntu.sources
sudo tee /etc/apt/sources.list.d/arm64-ports.list > /dev/null <<'EOF'
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports noble main restricted universe multiverse
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports noble-updates main restricted universe multiverse
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports noble-security main restricted universe multiverse
EOF
sudo apt-get update
sudo apt-get -y install --no-install-recommends \
cmake ninja-build \
gcc-aarch64-linux-gnu g++-aarch64-linux-gnu \
libsdl2-dev:arm64 libsdl2-mixer-dev:arm64 \
libsdl2-ttf-dev:arm64 libsdl2-image-dev:arm64 \
libgtest-dev:arm64 \
libspdlog-dev:arm64 libfmt-dev:arm64 \
libpng-dev:arm64 \
nlohmann-json3-dev \
libwxgtk3.2-dev:arm64 \
- name: Configure
run: |
mkdir -p build_Release
cd build_Release
cmake -GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_SYSTEM_NAME=Linux \
-DCMAKE_SYSTEM_PROCESSOR=aarch64 \
-DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc \
-DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ \
-DUSE_64_BIT=True \
-DGITHUB_CI_COMPATIBILITY_PATH="${{ env.GITHUB_CI_COMPATIBILITY_PATH }}" \
${{ github.workspace }}/src
- name: Build
run: |
cd build_Release
ninja
- name: Package (tar.gz)
run: |
mkdir -p remc2-linux-arm64
find build_Release -maxdepth 3 -name "remc2" -type f -exec cp {} remc2-linux-arm64/ \;
find build_Release -maxdepth 3 -name "remc2-editor" -type f -exec cp {} remc2-linux-arm64/ \; || true
cp src/config.json remc2-linux-arm64/
cp "src/Install Guide.txt" remc2-linux-arm64/
cp src/check_install.sh remc2-linux-arm64/
tar -czf remc2-linux-arm64.tar.gz remc2-linux-arm64/
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: remc2-linux-arm64
path: remc2-linux-arm64.tar.gz
# ─────────────────────────────────────────────
# Linux – Ubuntu 22.04 x86_64
# ─────────────────────────────────────────────
build-linux-ubuntu22:
name: Linux Ubuntu 22.04 (x86_64)
runs-on: ubuntu-22.04
env:
GITHUB_CI_COMPATIBILITY_PATH: /usr/lib/x86_64-linux-gnu
steps:
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get -y install --no-install-recommends \
build-essential \
cmake ninja-build \
libsdl2-dev libsdl2-mixer-dev \
libsdl2-ttf-dev libsdl2-image-dev \
libgtest-dev \
libspdlog-dev libfmt-dev \
nlohmann-json3-dev \
clang-tidy \
libgtk-3-dev libgl1-mesa-dev
- name: Install wxWidgets 3.2 from source
run: |
wget -q https://github.com/wxWidgets/wxWidgets/releases/download/v3.2.6/wxWidgets-3.2.6.tar.bz2
tar -xf wxWidgets-3.2.6.tar.bz2
cd wxWidgets-3.2.6
./configure --with-gtk=3 --with-opengl --disable-tests --prefix=/usr/local
make -j$(nproc)
sudo make install
sudo ldconfig
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
path: src
- name: Configure
run: |
mkdir -p build_Release
cd build_Release
cmake -GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DUSE_64_BIT=True \
-DGITHUB_CI_COMPATIBILITY_PATH="${{ env.GITHUB_CI_COMPATIBILITY_PATH }}" \
${{ github.workspace }}/src
- name: Build
run: |
cd build_Release
ninja
- name: Package (tar.gz)
run: |
mkdir -p remc2-linux-ubuntu22-x86_64
find build_Release -maxdepth 3 -name "remc2" -type f -exec cp {} remc2-linux-ubuntu22-x86_64/ \;
find build_Release -maxdepth 3 -name "remc2-editor" -type f -exec cp {} remc2-linux-ubuntu22-x86_64/ \; || true
cp src/config.json remc2-linux-ubuntu22-x86_64/
cp "src/Install Guide.txt" remc2-linux-ubuntu22-x86_64/
cp src/check_install.sh remc2-linux-ubuntu22-x86_64/
tar -czf remc2-linux-ubuntu22-x86_64.tar.gz remc2-linux-ubuntu22-x86_64/
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: remc2-linux-ubuntu22-x86_64
path: remc2-linux-ubuntu22-x86_64.tar.gz
# ─────────────────────────────────────────────
# GitHub Release
# ─────────────────────────────────────────────
release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs:
- build-windows
- build-installer
- build-linux
- build-linux-ubuntu22
- build-linux-arm64
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: dist/
- name: List dist
run: find dist/ -type f
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: "Magic Carpet 2 HD ${{ github.ref_name }}"
draft: false
prerelease: ${{ contains(github.ref_name, '-rc') || contains(github.ref_name, '-beta') || contains(github.ref_name, '-alpha') }}
generate_release_notes: true
files: |
dist/remc2-win-x64/remc2-win-x64.zip
dist/remc2-win-x86/remc2-win-x86.zip
dist/installer-x64/Magic.Carpet.2.HD.x64.msi
dist/installer-x86/Magic.Carpet.2.HD.x86.msi
dist/remc2-linux-x86_64/remc2-linux-x86_64.tar.gz
dist/remc2-linux-ubuntu22-x86_64/remc2-linux-ubuntu22-x86_64.tar.gz
dist/remc2-linux-arm64/remc2-linux-arm64.tar.gz