Skip to content

Windows SDL Build

Windows SDL Build #22

name: Windows SDL Build
on:
workflow_dispatch:
push:
tags:
- "v*"
jobs:
windows-sdl:
runs-on: windows-latest
defaults:
run:
shell: pwsh
steps:
- name: Check Out Repository
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
- name: Install Swift
uses: compnerd/gha-setup-swift@c8363f1001fbb4b12d127c432f9eaadec5f56e8c
with:
swift-version: swift-6.3-branch
swift-build: 6.3-DEVELOPMENT-SNAPSHOT-2026-02-27-a
update-sdk-modules: true
- name: Set Up Visual Studio Build Environment
uses: compnerd/gha-setup-vsdevenv@5eb3eae1490d4f7875d574c4973539f69109700d
with:
arch: amd64
- name: Verify Swift Toolchain
run: swift --version
- name: Download SDL3 SDK
run: |
$sdlVersion = "3.4.2"
$archiveName = "SDL3-devel-$sdlVersion-VC.zip"
$archivePath = Join-Path $env:RUNNER_TEMP $archiveName
$extractRoot = Join-Path $env:RUNNER_TEMP "sdl3-sdk"
$downloadUrl = "https://github.com/libsdl-org/SDL/releases/download/release-$sdlVersion/$archiveName"
$expectedSha256 = "fd4c60400634df13a86b69432b22b32f23bccd6a2f4c6a34b42b471c65eb4fd2"
Invoke-WebRequest -Uri $downloadUrl -OutFile $archivePath
$actualSha256 = (Get-FileHash -Algorithm SHA256 -LiteralPath $archivePath).Hash.ToLowerInvariant()
if ($actualSha256 -ne $expectedSha256) {
throw "SDL3 SDK hash mismatch. Expected $expectedSha256 but found $actualSha256."
}
Expand-Archive -LiteralPath $archivePath -DestinationPath $extractRoot -Force
$sdlRoot = Join-Path $extractRoot "SDL3-$sdlVersion"
if (-not (Test-Path $sdlRoot)) {
throw "SDL3 SDK was not extracted where expected: $sdlRoot"
}
"SDL3_ROOT=$sdlRoot" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
"C_INCLUDE_PATH=$($sdlRoot)\include" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
$libraryPath = "$($sdlRoot)\lib\x64"
if ($env:LIB) {
"LIB=$libraryPath;$env:LIB" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
} else {
"LIB=$libraryPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
}
- name: Build Release Binary
run: swift build -c release
- name: Stage Windows Artifact
run: |
$buildRoot = Resolve-Path ".build"
$gameExe = Get-ChildItem -Path $buildRoot -Filter "Game.exe" -Recurse |
Where-Object { $_.FullName -match '[\\/]release[\\/]' } |
Select-Object -First 1
if (-not $gameExe) {
throw "Unable to locate the built Game.exe artifact."
}
$releaseDir = Split-Path -Parent $gameExe.FullName
$dist = Join-Path $env:RUNNER_TEMP "Codexitma-win64"
New-Item -ItemType Directory -Path $dist -Force | Out-Null
Copy-Item -LiteralPath $gameExe.FullName -Destination (Join-Path $dist "Codexitma.exe")
Get-ChildItem -Path $releaseDir |
Where-Object { $_.Name -like "Game*" -and $_.Name -ne $gameExe.Name } |
ForEach-Object {
Copy-Item -LiteralPath $_.FullName -Destination (Join-Path $dist $_.Name) -Recurse -Force
}
Get-ChildItem -Path $releaseDir -Filter "*.dll" -File |
ForEach-Object {
Copy-Item -LiteralPath $_.FullName -Destination (Join-Path $dist $_.Name) -Force
}
$targetInfo = swiftc -print-target-info | ConvertFrom-Json
$runtimeDirs = @()
if ($targetInfo.paths.runtimeLibraryPaths) {
$runtimeDirs += $targetInfo.paths.runtimeLibraryPaths
}
if ($targetInfo.paths.runtimeResourcePath) {
$runtimeDirs += $targetInfo.paths.runtimeResourcePath
}
$runtimeDirs |
Where-Object { $_ -and (Test-Path $_) } |
Select-Object -Unique |
ForEach-Object {
Get-ChildItem -Path $_ -Filter "*.dll" -File -ErrorAction SilentlyContinue |
ForEach-Object {
Copy-Item -LiteralPath $_.FullName -Destination (Join-Path $dist $_.Name) -Force
}
}
$sdlDllCandidates = @(
(Join-Path $env:SDL3_ROOT "lib\x64\SDL3.dll"),
(Join-Path $env:SDL3_ROOT "bin\x64\SDL3.dll")
)
$sdlDll = $sdlDllCandidates | Where-Object { Test-Path $_ } | Select-Object -First 1
if ($sdlDll) {
Copy-Item -LiteralPath $sdlDll -Destination (Join-Path $dist "SDL3.dll")
} else {
throw "SDL3.dll was not found in the downloaded SDK."
}
- name: Upload Windows Artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: Codexitma-win64
path: ${{ runner.temp }}/Codexitma-win64