Skip to content

Code refactor: stage 3 #4

Code refactor: stage 3

Code refactor: stage 3 #4

Workflow file for this run

name: Windows x64 Build & Package
on:
push:
branches: [ main, master ]
tags: [ 'v*' ]
pull_request:
jobs:
build:
runs-on: windows-latest
env:
BUILD_TYPE: Release
OUTPUT_DIR: Build
ARCH: x64
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# Fetch full history for tags/release notes; no submodules when using FetchContent
fetch-depth: 0
- name: Show toolchain versions
shell: pwsh
run: |
cmake --version
ninja --version || echo "Ninja not used (VS generator expected)"
# Cache CMake's fetched dependencies (e.g., build/_deps) to speed up runs
- name: Cache CMake deps
uses: actions/cache@v4
with:
path: |
build/_deps
key: ${{ runner.os }}-cmake-deps-${{ hashFiles('cmake/**', '**/CMakeLists.txt') }}
- name: Configure (CMake, x64)
shell: pwsh
run: >
cmake -S . -B build
-A $env:ARCH
-DCMAKE_BUILD_TYPE=$env:BUILD_TYPE
- name: Build
shell: pwsh
run: cmake --build build --config $env:BUILD_TYPE --parallel
# Validate that post-build copied resources are present next to the exe
- name: Verify outputs
shell: pwsh
run: |
$exe = Join-Path $PWD "$env:OUTPUT_DIR/SuperMario.exe"
if (-not (Test-Path $exe)) { throw "SuperMario.exe not found at $exe" }
$res = Join-Path $PWD "$env:OUTPUT_DIR/res"
if (-not (Test-Path $res)) { throw "res folder not found under $env:OUTPUT_DIR" }
Write-Host "Artifacts OK."
- name: Package zip (exe + res/)
shell: pwsh
run: |
$binDir = Join-Path $PWD $env:OUTPUT_DIR
$exe = Join-Path $binDir "SuperMario.exe"
$res = Join-Path $binDir "res"
$zipName = "SuperMario-x64-${{ env.BUILD_TYPE }}.zip"
if (Test-Path $zipName) { Remove-Item $zipName -Force }
# Include exactly the exe and the res folder (folder preserved at archive root)
Compress-Archive -Path $exe, $res -DestinationPath $zipName
Write-Host "Created $zipName"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: SuperMario-x64-${{ env.BUILD_TYPE }}
path: SuperMario-x64-${{ env.BUILD_TYPE }}.zip
if-no-files-found: error
# Publish release asset only for tags starting with 'v'
- name: Upload to GitHub Release (on tag)
if: startsWith(github.ref, 'refs/tags/v')
uses: softprops/action-gh-release@v2
with:
files: SuperMario-x64-${{ env.BUILD_TYPE }}.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}