Skip to content

Commit 87dbf9a

Browse files
authored
Refactor GitHub Actions build workflow
1 parent e62caeb commit 87dbf9a

File tree

1 file changed

+18
-26
lines changed

1 file changed

+18
-26
lines changed

.github/workflows/build.yml

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@ name: Build (Win32 Debug & Release — DLLs only; Debug symbols)
33
on:
44
push:
55
branches: [ main ]
6-
tags: [ '*' ] # optional
76
release:
8-
types: [ published ] # runs when you click "Publish release"
7+
types: [ published ] # runs when you click "Publish release"
98
workflow_dispatch:
109

1110
permissions:
12-
contents: write # delete/upload release assets
11+
contents: write
1312

1413
env:
1514
CMAKE_BUILD_PARALLEL_LEVEL: 8
@@ -35,7 +34,7 @@ jobs:
3534
- name: Build (${{ matrix.config }})
3635
run: cmake --build ${{ github.workspace }}\build --config ${{ matrix.config }} -- /m
3736

38-
# CI artifacts for quick download: DLLs + PDBs (if present). No .lib/.exe.
37+
# CI artifacts for convenience: only DLLs + (if present) PDBs
3938
- name: Upload CI artifacts (${{ matrix.config }})
4039
uses: actions/upload-artifact@v4
4140
with:
@@ -45,9 +44,7 @@ jobs:
4544
${{ github.workspace }}\build\**\${{ matrix.config }}\*.pdb
4645
if-no-files-found: warn
4746

48-
# ----- Release publishing (only when a GitHub Release is published) -----
49-
50-
# Remove existing assets with our names to avoid stale uploads
47+
# Remove existing assets with our names (avoids stale uploads)
5148
- name: Remove existing release assets
5249
if: github.event_name == 'release' && github.event.action == 'published'
5350
uses: actions/github-script@v7
@@ -68,7 +65,7 @@ jobs:
6865
}
6966
}
7067
71-
# Stage only the files we want, zip them, print contents, and block .lib
68+
# Package from a clean staging folder; PRINT filenames inside each zip
7269
- name: Package (${{ matrix.config }})
7370
if: github.event_name == 'release' && github.event.action == 'published'
7471
shell: pwsh
@@ -80,13 +77,14 @@ jobs:
8077
$out = "$root\out"
8178
8279
# Collect only this config's files
83-
$all = Get-ChildItem -Path $bld -Recurse -File | Where-Object { $_.FullName -match "\\$cfg\\" }
80+
$all = Get-ChildItem -Path $bld -Recurse -File | Where-Object { $_.FullName -match ("\\{0}\\" -f $cfg) }
8481
$bins = @($all | Where-Object { $_.Extension -ieq ".dll" } | Select-Object -Expand FullName)
8582
$syms = @($all | Where-Object { $_.Extension -ieq ".pdb" } | Select-Object -Expand FullName)
8683
8784
# Clean staging and create folders
8885
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue $stage
89-
New-Item -ItemType Directory -Force -Path "$stage\binaries","$stage\symbols" | Out-Null
86+
New-Item -ItemType Directory -Force -Path "$stage\binaries" | Out-Null
87+
if ($cfg -eq "Debug") { New-Item -ItemType Directory -Force -Path "$stage\symbols" | Out-Null }
9088
New-Item -ItemType Directory -Force -Path $out | Out-Null
9189
9290
# Copy ONLY what we want to ship
@@ -107,36 +105,30 @@ jobs:
107105
if ($symFiles) { Compress-Archive -Path $symFiles -DestinationPath $zipSym -Force }
108106
}
109107
110-
# Print zip contents and FAIL if any .lib is present
108+
# Print zip contents (no errors, just logs)
111109
Add-Type -AssemblyName System.IO.Compression.FileSystem
112-
function Show-And-VerifyZip([string]$zipPath, [string]$label) {
110+
function Show-Zip([string]$zipPath, [string]$label) {
113111
if (Test-Path $zipPath) {
114112
$z = [System.IO.Compression.ZipFile]::OpenRead($zipPath)
115113
try {
116114
Write-Host ("ZIP ({0}): {1}" -f $label, $zipPath)
117-
foreach ($e in $z.Entries) {
118-
Write-Host (" - {0}" -f $e.FullName)
119-
if ($e.FullName.EndsWith('.lib',[String]::Comparison::OrdinalIgnoreCase)) {
120-
throw ("Found .lib in {0}: {1}" -f $zipPath, $e.FullName)
121-
}
122-
}
115+
foreach ($e in $z.Entries) { Write-Host (" - {0}" -f $e.FullName) }
123116
} finally { $z.Dispose() }
124117
} else {
125118
Write-Host ("ZIP ({0}): (not created)" -f $label)
126119
}
127120
}
128-
# .NET enum handy alias
129-
[StringComparison]$null = [StringComparison]::OrdinalIgnoreCase
130-
131-
Show-And-VerifyZip $zipBin "binaries"
132-
if ($cfg -eq "Debug") { Show-And-VerifyZip $zipSym "symbols" }
121+
Show-Zip $zipBin "binaries"
122+
if ($cfg -eq "Debug") { Show-Zip $zipSym "symbols" }
133123
134124
# Also log staged files
135-
Write-Host "Binaries staged:"; Get-ChildItem "$stage\binaries" -File | ForEach-Object { Write-Host (" - {0}" -f $_.Name) }
125+
Write-Host "Staged binaries:"
126+
Get-ChildItem "$stage\binaries" -File | ForEach-Object { Write-Host (" - {0}" -f $_.Name) }
136127
if ($cfg -eq "Debug") {
137-
Write-Host "Symbols staged:"; Get-ChildItem "$stage\symbols" -File | ForEach-Object { Write-Host (" - {0}" -f $_.Name) }
128+
Write-Host "Staged symbols:"
129+
Get-ChildItem "$stage\symbols" -File | ForEach-Object { Write-Host (" - {0}" -f $_.Name) }
138130
} else {
139-
Write-Host "Symbols staged: (none for Release)"
131+
Write-Host "Staged symbols: (none for Release)"
140132
}
141133
142134
# Upload assets to the GitHub Release

0 commit comments

Comments
 (0)