Skip to content

Commit 86ec367

Browse files
committed
Use vcpkg and artifact zips in CI
Switch CI to use vcpkg across Windows, Linux and macOS: add FORCE_JAVASCRIPT_ACTIONS_TO_NODE24 env, cache vcpkg, clone/bootstrap vcpkg with retry logic, and install SFML via vcpkg on each platform. Configure CMake to use the vcpkg toolchain and target triplets. Package build outputs into per-platform zip artifacts and upload those artifacts (update upload paths). Rename the Ubuntu job to build-linux and update create-release job dependencies to match. Includes improved Windows PowerShell steps and more robust install/bootstrap retrying.
1 parent 5c8df62 commit 86ec367

1 file changed

Lines changed: 132 additions & 36 deletions

File tree

.github/workflows/ci.yml

Lines changed: 132 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ on:
88
branches: [ main, master ]
99
workflow_dispatch:
1010

11+
env:
12+
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
13+
1114
jobs:
1215
build-windows:
1316
name: Build (Windows, MSVC, vcpkg)
@@ -16,93 +19,184 @@ jobs:
1619
- name: Checkout
1720
uses: actions/checkout@v4
1821

19-
- name: Setup vcpkg
20-
env:
21-
VCPKG_ROOT: ${{ runner.temp }}\vcpkg
22-
run: |
23-
git clone https://github.com/microsoft/vcpkg "%VCPKG_ROOT%"
24-
powershell -Command "& '%VCPKG_ROOT%/bootstrap-vcpkg.bat'"
22+
- name: Cache vcpkg
23+
uses: actions/cache@v4
24+
with:
25+
path: ${{ runner.temp }}\vcpkg
26+
key: vcpkg-${{ runner.os }}-${{ hashFiles('**/vcpkg.json') }}
27+
restore-keys: |
28+
vcpkg-${{ runner.os }}-
2529
26-
- name: Install SFML via vcpkg (x64)
27-
env:
28-
VCPKG_ROOT: ${{ runner.temp }}\vcpkg
30+
- name: Setup vcpkg (Windows)
31+
shell: pwsh
32+
run: |
33+
$env:VCPKG_ROOT = "${{ runner.temp }}\vcpkg"
34+
if (!(Test-Path -Path $env:VCPKG_ROOT)) {
35+
git clone https://github.com/microsoft/vcpkg $env:VCPKG_ROOT
36+
}
37+
$attempt = 0
38+
while ($true) {
39+
try {
40+
& "$env:VCPKG_ROOT\bootstrap-vcpkg.bat"
41+
break
42+
} catch {
43+
$attempt++
44+
if ($attempt -ge 3) { throw "vcpkg bootstrap failed after 3 attempts" }
45+
Start-Sleep -s (5 * $attempt)
46+
}
47+
}
48+
49+
- name: Install SFML (vcpkg x64-windows)
50+
shell: pwsh
2951
run: |
30-
"%VCPKG_ROOT%\vcpkg.exe" install sfml[graphics,window,system]:x64-windows
52+
$env:VCPKG_ROOT = "${{ runner.temp }}\vcpkg"
53+
$vcpkg = Join-Path $env:VCPKG_ROOT "vcpkg.exe"
54+
$attempt = 0
55+
while ($true) {
56+
try {
57+
& $vcpkg install sfml[graphics,window,system]:x64-windows
58+
break
59+
} catch {
60+
$attempt++
61+
if ($attempt -ge 3) { throw "vcpkg install failed after 3 attempts" }
62+
Start-Sleep -s (5 * $attempt)
63+
}
64+
}
3165
3266
- name: Configure CMake (Windows)
33-
env:
34-
VCPKG_ROOT: ${{ runner.temp }}\vcpkg
67+
shell: pwsh
3568
run: |
3669
$toolchain = "${{ runner.temp }}\vcpkg\scripts\buildsystems\vcpkg.cmake"
3770
cmake -S . -B build -G "Visual Studio 17 2022" -A x64 -DCMAKE_TOOLCHAIN_FILE="$toolchain" -DVCPKG_TARGET_TRIPLET=x64-windows -DCMAKE_BUILD_TYPE=Release
3871
3972
- name: Build (Release)
4073
run: cmake --build build --config Release -- /m
4174

42-
- name: Collect artifacts (Windows)
75+
- name: Package Windows artifacts
76+
shell: pwsh
77+
run: |
78+
$out = "build\artifacts_windows"
79+
Remove-Item -Recurse -Force $out -ErrorAction SilentlyContinue
80+
New-Item -ItemType Directory -Path $out | Out-Null
81+
Copy-Item -Path "build\bin\Release\*" -Destination $out -Recurse -Force -ErrorAction SilentlyContinue
82+
# if dlls are alongside build\bin, copy them as well
83+
if (Test-Path "build\bin") {
84+
Copy-Item -Path "build\bin\*" -Destination $out -Recurse -Force -ErrorAction SilentlyContinue
85+
}
86+
Compress-Archive -Path $out\* -DestinationPath build\IsometricGrid-SFML-windows.zip -Force
87+
88+
- name: Upload artifact (Windows)
4389
uses: actions/upload-artifact@v4
4490
with:
4591
name: IsometricGrid-SFML-windows
46-
path: |
47-
build/bin/Release/**
48-
build/bin/**
92+
path: build/IsometricGrid-SFML-windows.zip
4993

50-
build-ubuntu:
51-
name: Build (Ubuntu, GCC/Clang)
94+
build-linux:
95+
name: Build (Ubuntu, vcpkg)
5296
runs-on: ubuntu-latest
5397
steps:
5498
- uses: actions/checkout@v4
5599

56-
- name: Install dependencies (apt)
100+
- name: Cache vcpkg
101+
uses: actions/cache@v4
102+
with:
103+
path: ${{ runner.temp }}/vcpkg
104+
key: vcpkg-${{ runner.os }}-${{ hashFiles('**/vcpkg.json') }}
105+
restore-keys: |
106+
vcpkg-${{ runner.os }}-
107+
108+
- name: Setup vcpkg (Linux)
109+
run: |
110+
export VCPKG_ROOT="${RUNNER_TEMP}/vcpkg"
111+
if [ ! -d "$VCPKG_ROOT" ]; then
112+
git clone https://github.com/microsoft/vcpkg "$VCPKG_ROOT"
113+
fi
114+
cd "$VCPKG_ROOT"
115+
./bootstrap-vcpkg.sh || (sleep 5 && ./bootstrap-vcpkg.sh) || (sleep 10 && ./bootstrap-vcpkg.sh)
116+
117+
- name: Install SFML (vcpkg x64-linux)
57118
run: |
58-
sudo apt update
59-
sudo apt install -y build-essential cmake libsfml-dev
119+
export VCPKG_ROOT="${RUNNER_TEMP}/vcpkg"
120+
"$VCPKG_ROOT/vcpkg" install sfml[graphics,window,system]:x64-linux
60121
61122
- name: Configure CMake (Linux)
62-
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
123+
run: |
124+
export VCPKG_ROOT="${RUNNER_TEMP}/vcpkg"
125+
TOOLCHAIN="$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake"
126+
cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE="$TOOLCHAIN" -DVCPKG_TARGET_TRIPLET=x64-linux -DCMAKE_BUILD_TYPE=Release
63127
64128
- name: Build (Release)
65129
run: cmake --build build --config Release -- -j$(nproc)
66130

67-
- name: Collect artifacts (Linux)
131+
- name: Package Linux artifacts
132+
run: |
133+
rm -rf build/artifacts_linux || true
134+
mkdir -p build/artifacts_linux
135+
cp -r build/bin/* build/artifacts_linux/ 2>/dev/null || true
136+
cd build && zip -r IsometricGrid-SFML-linux.zip artifacts_linux || true
137+
138+
- name: Upload artifact (Linux)
68139
uses: actions/upload-artifact@v4
69140
with:
70141
name: IsometricGrid-SFML-linux
71-
path: |
72-
build/bin/**
73-
build/bin/Release/**
142+
path: build/IsometricGrid-SFML-linux.zip
74143

75144
build-macos:
76-
name: Build (macOS, clang + brew)
145+
name: Build (macOS, vcpkg)
77146
runs-on: macos-latest
78147
steps:
79148
- uses: actions/checkout@v4
80149

81-
- name: Install SFML (Homebrew)
150+
- name: Cache vcpkg
151+
uses: actions/cache@v4
152+
with:
153+
path: ${{ runner.temp }}/vcpkg
154+
key: vcpkg-${{ runner.os }}-${{ hashFiles('**/vcpkg.json') }}
155+
restore-keys: |
156+
vcpkg-${{ runner.os }}-
157+
158+
- name: Setup vcpkg (macOS)
159+
run: |
160+
VCPKG_ROOT="${RUNNER_TEMP}/vcpkg"
161+
if [ ! -d "$VCPKG_ROOT" ]; then
162+
git clone https://github.com/microsoft/vcpkg "$VCPKG_ROOT"
163+
fi
164+
cd "$VCPKG_ROOT"
165+
./bootstrap-vcpkg.sh || (sleep 5 && ./bootstrap-vcpkg.sh) || (sleep 10 && ./bootstrap-vcpkg.sh)
166+
167+
- name: Install SFML (vcpkg x64-osx)
82168
run: |
83-
brew update
84-
brew install sfml
169+
VCPKG_ROOT="${RUNNER_TEMP}/vcpkg"
170+
"$VCPKG_ROOT/vcpkg" install sfml[graphics,window,system]:x64-osx
85171
86172
- name: Configure CMake (macOS)
87-
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
173+
run: |
174+
VCPKG_ROOT="${RUNNER_TEMP}/vcpkg"
175+
TOOLCHAIN="$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake"
176+
cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE="$TOOLCHAIN" -DVCPKG_TARGET_TRIPLET=x64-osx -DCMAKE_BUILD_TYPE=Release
88177
89178
- name: Build (Release)
90179
run: cmake --build build --config Release -- -j$(sysctl -n hw.ncpu)
91180

92-
- name: Collect artifacts (macOS)
181+
- name: Package macOS artifacts
182+
run: |
183+
rm -rf build/artifacts_macos || true
184+
mkdir -p build/artifacts_macos
185+
cp -r build/bin/* build/artifacts_macos/ 2>/dev/null || true
186+
cd build && zip -r IsometricGrid-SFML-macos.zip artifacts_macos || true
187+
188+
- name: Upload artifact (macOS)
93189
uses: actions/upload-artifact@v4
94190
with:
95191
name: IsometricGrid-SFML-macos
96-
path: |
97-
build/bin/**
98-
build/bin/Release/**
192+
path: build/IsometricGrid-SFML-macos.zip
99193

100194
create-release:
101195
name: Create release (on tag)
102196
runs-on: ubuntu-latest
103197
needs:
104198
- build-windows
105-
- build-ubuntu
199+
- build-linux
106200
- build-macos
107201
if: startsWith(github.ref, 'refs/tags/v')
108202
steps:
@@ -142,13 +236,15 @@ jobs:
142236
asset_path: release-artifacts/windows
143237
asset_name: IsometricGrid-SFML-windows.zip
144238
asset_content_type: application/zip
239+
145240
- name: Upload Linux asset
146241
uses: actions/upload-release-asset@v1
147242
with:
148243
upload_url: ${{ steps.create_release.outputs.upload_url }}
149244
asset_path: release-artifacts/linux
150245
asset_name: IsometricGrid-SFML-linux.zip
151246
asset_content_type: application/zip
247+
152248
- name: Upload macOS asset
153249
uses: actions/upload-release-asset@v1
154250
with:

0 commit comments

Comments
 (0)