Skip to content

Commit 31a9716

Browse files
committed
ci: Don't double-zip.
1 parent 9048d8c commit 31a9716

File tree

1 file changed

+31
-60
lines changed

1 file changed

+31
-60
lines changed

.github/workflows/build.yml

Lines changed: 31 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -121,101 +121,72 @@ jobs:
121121
- name: Build installer
122122
run: msbuild /p:Platform=${{ matrix.platform }} /p:Configuration=${{ matrix.configuration }} /p:SolutionDir="$env:GITHUB_WORKSPACE\" .\Installer\Installer.wixproj
123123

124-
- name: Package .zip with versioned filename
124+
- name: Package portable bundle (folder)
125125
shell: pwsh
126126
run: |
127-
$version = "${{ steps.set_version.outputs.version }}"
128-
$outDir = "$env:GITHUB_WORKSPACE\Installer\Builds"
129-
New-Item -ItemType Directory -Force -Path $outDir | Out-Null
130-
$zipArchive = Join-Path $outDir "dmdext-v$version-${{ matrix.platform }}.zip"
127+
$version = "${{ steps.set_version.outputs.version }}"
128+
$outDir = "$env:GITHUB_WORKSPACE\Installer\Builds"
129+
$bundleDir = Join-Path $outDir "dmdext-v$version-${{ matrix.platform }}"
130+
New-Item -ItemType Directory -Force -Path $bundleDir | Out-Null
131131
132-
Compress-Archive -Path "$env:GITHUB_WORKSPACE\Console\bin\${{ matrix.platform }}\${{ matrix.configuration }}\dmdext.exe" -DestinationPath $zipArchive -Force
133-
Compress-Archive -Path "$env:GITHUB_WORKSPACE\Console\bin\${{ matrix.platform }}\${{ matrix.configuration }}\dmdext.log.config" -Update -DestinationPath $zipArchive
134-
Compress-Archive -Path "$env:GITHUB_WORKSPACE\Console\ProPinballSlave.bat" -Update -DestinationPath $zipArchive
132+
# Core binaries/config
133+
Copy-Item "$env:GITHUB_WORKSPACE\Console\bin\${{ matrix.platform }}\${{ matrix.configuration }}\dmdext.exe" -Destination $bundleDir -Force
134+
Copy-Item "$env:GITHUB_WORKSPACE\Console\bin\${{ matrix.platform }}\${{ matrix.configuration }}\dmdext.log.config" -Destination $bundleDir -Force
135+
Copy-Item "$env:GITHUB_WORKSPACE\Console\ProPinballSlave.bat" -Destination $bundleDir -Force
135136
137+
# PinMAME device bits
136138
$dllSuffix = if ('${{ matrix.platform }}' -eq 'x64') { '64' } else { '' }
137-
Compress-Archive -Path "$env:GITHUB_WORKSPACE\PinMameDevice\bin\${{ matrix.platform }}\${{ matrix.configuration }}\DmdDevice$dllSuffix.dll" -Update -DestinationPath $zipArchive
138-
Compress-Archive -Path "$env:GITHUB_WORKSPACE\PinMameDevice\bin\${{ matrix.platform }}\${{ matrix.configuration }}\DmdDevice.log.config" -Update -DestinationPath $zipArchive
139+
Copy-Item "$env:GITHUB_WORKSPACE\PinMameDevice\bin\${{ matrix.platform }}\${{ matrix.configuration }}\DmdDevice$dllSuffix.dll" -Destination $bundleDir -Force
140+
Copy-Item "$env:GITHUB_WORKSPACE\PinMameDevice\bin\${{ matrix.platform }}\${{ matrix.configuration }}\DmdDevice.log.config" -Destination $bundleDir -Force
139141
140-
# add ini template as folder (no nested zip)
141-
$iniTemp = "$env:GITHUB_WORKSPACE\ini-template"
142-
New-Item -Type Directory -Force $iniTemp | Out-Null
143-
Copy-Item -Path "$env:GITHUB_WORKSPACE\PinMameDevice\DmdDevice.ini" -Destination $iniTemp
144-
Compress-Archive -Path "$iniTemp\*" -Update -DestinationPath $zipArchive
145-
Remove-Item $iniTemp -Recurse -Force
142+
# ini template as a folder
143+
New-Item -ItemType Directory -Force -Path (Join-Path $bundleDir 'ini-template') | Out-Null
144+
Copy-Item "$env:GITHUB_WORKSPACE\PinMameDevice\DmdDevice.ini" -Destination (Join-Path $bundleDir 'ini-template\DmdDevice.ini') -Force
146145
147-
# include data folder contents as 'dmdext' directory
148-
Rename-Item "$env:GITHUB_WORKSPACE\PinMameDevice\data" "$env:GITHUB_WORKSPACE\PinMameDevice\dmdext"
149-
Compress-Archive -Path "$env:GITHUB_WORKSPACE\PinMameDevice\dmdext\*" -Update -DestinationPath $zipArchive
150-
Rename-Item "$env:GITHUB_WORKSPACE\PinMameDevice\dmdext" "$env:GITHUB_WORKSPACE\PinMameDevice\data"
146+
# data folder contents under a 'dmdext' subfolder
147+
New-Item -ItemType Directory -Force -Path (Join-Path $bundleDir 'dmdext') | Out-Null
148+
Copy-Item "$env:GITHUB_WORKSPACE\PinMameDevice\data\*" -Destination (Join-Path $bundleDir 'dmdext') -Recurse -Force
151149
152150
- name: Rename MSI to versioned filename
153151
shell: pwsh
154152
run: |
155153
$ErrorActionPreference = 'Stop'
156-
157154
$version = "${{ steps.set_version.outputs.version }}"
158155
$root = $env:GITHUB_WORKSPACE
159156
$outDir = Join-Path $root 'Installer\Builds'
160157
New-Item -ItemType Directory -Force -Path $outDir | Out-Null
161158
162-
# Look for the latest MSI in common WiX output locations
163159
$searchRoots = @(
164160
(Join-Path $root 'Installer\Builds'),
165161
(Join-Path $root 'Installer\bin'),
166-
(Join-Path $root 'Installer') # fallback
162+
(Join-Path $root 'Installer')
167163
) | Get-Unique
168164
169-
$candidates = @()
170-
foreach ($dir in $searchRoots) {
171-
if (Test-Path $dir) {
172-
$candidates += Get-ChildItem -Path $dir -Filter *.msi -File -Recurse -ErrorAction SilentlyContinue
173-
}
174-
}
175-
176-
if (-not $candidates -or $candidates.Count -eq 0) {
177-
throw "No MSI found under: `n - $($searchRoots -join "`n - ")"
165+
$candidates = foreach ($dir in $searchRoots) {
166+
if (Test-Path $dir) { Get-ChildItem -Path $dir -Filter *.msi -File -Recurse -ErrorAction SilentlyContinue }
178167
}
179168
180-
# Pick the most recently written MSI
181-
$msi = $candidates | Sort-Object LastWriteTimeUtc -Descending | Select-Object -First 1
169+
if (-not $candidates) { throw "No MSI found under:`n - $($searchRoots -join "`n - ")" }
182170
171+
$msi = $candidates | Sort-Object LastWriteTimeUtc -Descending | Select-Object -First 1
183172
$target = Join-Path $outDir "dmdext-v$version-${{ matrix.platform }}.msi"
184173
185-
if ($msi.FullName -ieq $target) {
186-
Write-Host "MSI already has the correct name: $target"
187-
exit 0
188-
}
189-
190-
# Copy to the target name (more reliable on hosted runners), then remove the original
191-
Copy-Item -Path $msi.FullName -Destination $target -Force
192-
if (-not (Test-Path $target)) {
193-
throw "Failed to create target MSI at: $target"
194-
}
195-
196-
# Clean up the original if it lives elsewhere
197-
if ($msi.FullName -ne $target) {
198-
Remove-Item -Path $msi.FullName -Force
199-
}
200-
201-
Write-Host "MSI placed at: $target"
174+
if ($msi.FullName -ieq $target) { exit 0 }
175+
Copy-Item $msi.FullName $target -Force
176+
if ($msi.FullName -ne $target) { Remove-Item $msi.FullName -Force }
202177
203-
# Upload the already-zipped bundle WITHOUT re-compressing
204-
- name: Upload ZIP artifact
178+
- name: Upload portable bundle (single zip by GitHub)
205179
uses: actions/upload-artifact@v4
206180
with:
207-
name: dmdext-v${{ steps.set_version.outputs.version }}-${{ matrix.platform }}.zip
208-
path: ${{ github.workspace }}\Installer\Builds\dmdext-v${{ steps.set_version.outputs.version }}-${{ matrix.platform }}.zip
209-
compression-level: 0
181+
name: dmdext-v${{ steps.set_version.outputs.version }}-${{ matrix.platform }}
182+
path: ${{ github.workspace }}\Installer\Builds\dmdext-v${{ steps.set_version.outputs.version }}-${{ matrix.platform }}
210183
retention-days: 90
211184
if-no-files-found: error
212185

213-
# Upload the MSI as-is (not zipped)
214-
- name: Upload MSI artifact
186+
- name: Upload MSI (wrapped by GitHub)
215187
uses: actions/upload-artifact@v4
216188
with:
217-
name: dmdext-v${{ steps.set_version.outputs.version }}-${{ matrix.platform }}.msi
189+
name: dmdext-v${{ steps.set_version.outputs.version }}-${{ matrix.platform }}-msi
218190
path: ${{ github.workspace }}\Installer\Builds\dmdext-v${{ steps.set_version.outputs.version }}-${{ matrix.platform }}.msi
219-
compression-level: 0
220191
retention-days: 90
221192
if-no-files-found: error

0 commit comments

Comments
 (0)