|
1 | 1 | name: Windows x64 Build & Package |
2 | | - |
3 | 2 | on: |
4 | | - push: |
5 | | - branches: [ main, master ] |
6 | | - tags: [ 'v*' ] |
| 3 | + push: { branches: [ main, master ], tags: [ 'v*' ] } |
7 | 4 | pull_request: |
8 | | - |
9 | 5 | jobs: |
10 | | - build: |
| 6 | + build-windows: |
11 | 7 | runs-on: windows-latest |
12 | | - |
13 | 8 | env: |
14 | 9 | BUILD_TYPE: Release |
15 | 10 | OUTPUT_DIR: Build |
16 | 11 | ARCH: x64 |
17 | | - BUILD_DIR: build-x64 # per-arch build directory |
18 | | - |
| 12 | + BUILD_DIR: build-x64 |
19 | 13 | steps: |
20 | | - - name: Checkout |
21 | | - uses: actions/checkout@v4 |
22 | | - with: |
23 | | - fetch-depth: 0 |
24 | | - |
25 | | - - name: Show toolchain versions |
| 14 | + - uses: actions/checkout@v4 |
| 15 | + with: { fetch-depth: 0 } |
| 16 | + - name: Toolchain info |
26 | 17 | shell: pwsh |
27 | 18 | run: | |
28 | 19 | cmake --version |
29 | 20 | ninja --version || echo "Ninja not used (VS generator expected)" |
30 | | -
|
31 | | - # Ensure a clean build dir to avoid generator/platform mismatch |
32 | | - - name: Clean build dir (if exists) |
| 21 | + - name: Clean build dir |
33 | 22 | shell: pwsh |
34 | 23 | run: | |
35 | 24 | if (Test-Path $env:BUILD_DIR) { Remove-Item -Recurse -Force $env:BUILD_DIR } |
36 | | -
|
37 | | - # Cache only the per-arch _deps to avoid re-downloading SFML/tinyxml2 |
38 | | - - name: Cache CMake deps |
39 | | - uses: actions/cache@v4 |
| 25 | + - uses: actions/cache@v4 |
40 | 26 | with: |
41 | | - path: | |
42 | | - ${{ env.BUILD_DIR }}/_deps |
| 27 | + path: ${{ env.BUILD_DIR }}/_deps |
43 | 28 | key: ${{ runner.os }}-${{ env.ARCH }}-${{ env.BUILD_TYPE }}-cmake-deps-${{ hashFiles('cmake/**', '**/CMakeLists.txt') }} |
44 | | - |
45 | 29 | - name: Configure (CMake, x64) |
46 | 30 | shell: pwsh |
47 | 31 | run: > |
48 | | - cmake -S . -B $env:BUILD_DIR |
49 | | - -A $env:ARCH |
50 | | - -DCMAKE_BUILD_TYPE=$env:BUILD_TYPE |
51 | | -
|
| 32 | + cmake -S . -B $env:BUILD_DIR -A $env:ARCH -DCMAKE_BUILD_TYPE=$env:BUILD_TYPE |
52 | 33 | - name: Build |
53 | 34 | shell: pwsh |
54 | 35 | run: cmake --build $env:BUILD_DIR --config $env:BUILD_TYPE --parallel |
55 | | - |
56 | | - # Validate outputs: only the exe and res/ are required |
57 | 36 | - name: Verify outputs |
58 | 37 | shell: pwsh |
59 | 38 | run: | |
60 | 39 | $binDir = Join-Path $PWD $env:OUTPUT_DIR |
61 | | - $exe = Join-Path $binDir "SuperMario.exe" |
62 | | - $res = Join-Path $binDir "res" |
63 | | - if (-not (Test-Path $exe)) { throw "SuperMario.exe not found at $exe" } |
64 | | - if (-not (Test-Path $res)) { throw "res folder not found at $res" } |
65 | | - Write-Host "Artifacts OK: $exe and $res" |
66 | | -
|
67 | | - - name: Package zip (exe + res/) |
| 40 | + if (-not (Test-Path (Join-Path $binDir "SuperMario.exe"))) { throw "exe missing" } |
| 41 | + if (-not (Test-Path (Join-Path $binDir "res"))) { throw "res missing" } |
| 42 | + - name: Package zip (Windows) |
68 | 43 | shell: pwsh |
69 | 44 | run: | |
70 | 45 | $binDir = Join-Path $PWD $env:OUTPUT_DIR |
71 | | - $exe = Join-Path $binDir "SuperMario.exe" |
72 | | - $res = Join-Path $binDir "res" |
73 | | - $zipName = "SuperMario-x64-${{ env.BUILD_TYPE }}.zip" |
74 | | - if (Test-Path $zipName) { Remove-Item $zipName -Force } |
75 | | - Compress-Archive -Path $exe, $res -DestinationPath $zipName |
76 | | - Write-Host "Created $zipName" |
77 | | -
|
78 | | - - name: Upload artifact |
79 | | - uses: actions/upload-artifact@v4 |
| 46 | + $zip = "SuperMario-windows-x64-${{ env.BUILD_TYPE }}.zip" |
| 47 | + if (Test-Path $zip) { Remove-Item $zip -Force } |
| 48 | + Compress-Archive -Path (Join-Path $binDir "SuperMario.exe"), (Join-Path $binDir "res") -DestinationPath $zip |
| 49 | + - uses: actions/upload-artifact@v4 |
80 | 50 | with: |
81 | | - name: SuperMario-x64-${{ env.BUILD_TYPE }} |
82 | | - path: SuperMario-x64-${{ env.BUILD_TYPE }}.zip |
| 51 | + name: SuperMario-windows-x64-${{ env.BUILD_TYPE }} |
| 52 | + path: SuperMario-windows-x64-${{ env.BUILD_TYPE }}.zip |
83 | 53 | if-no-files-found: error |
84 | | - |
85 | 54 | - name: Upload to GitHub Release (on tag) |
86 | 55 | if: startsWith(github.ref, 'refs/tags/v') |
87 | 56 | uses: softprops/action-gh-release@v2 |
88 | 57 | with: |
89 | | - files: SuperMario-x64-${{ env.BUILD_TYPE }}.zip |
| 58 | + files: SuperMario-windows-x64-${{ env.BUILD_TYPE }}.zip |
90 | 59 | env: |
91 | 60 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments