scripts: make Build-Pack and Deploy-Brass cross-platform
Two small fixes that surface when running the deploy pipeline on a non-Windows host (we now do this on glados via the Telegram bridge): - Build-Pack.ps1: fall back to launcher/ModpackLauncher.csproj <Version> when Get-Item.VersionInfo.FileVersion returns empty. Linux PowerShell can't parse PE FileVersion from a Windows .exe, so the previous code threw "set <Version> in ModpackLauncher.csproj and republish" -- but the csproj <Version> *was* set, just not readable from a foreign PE. Appends ".0" so the embedded value still matches the 4-part form the Windows compile bakes in. - Deploy-Brass.ps1: prefer rsync where available, fall back to robocopy otherwise. robocopy is Windows-only and bails on Linux/macOS hosts.
This commit is contained in:
@@ -214,11 +214,26 @@ $overridesLocal = Join-Path $repoRoot 'pack\overrides'
|
||||
$shareFiles = Join-Path $DeployShare 'files'
|
||||
if ($shouldRunPack -and (Test-Path $overridesLocal)) {
|
||||
Step "Mirror pack/overrides/ -> $shareFiles" {
|
||||
# /MIR makes destination match source (deletes orphan files in $shareFiles).
|
||||
# /XJ skips junctions, /R:1 /W:1 keeps retry behaviour sane on flaky shares.
|
||||
robocopy $overridesLocal $shareFiles /MIR /XJ /R:1 /W:1 /NFL /NDL /NJH /NJS /NP | Out-Host
|
||||
# Robocopy returns 0-7 for success-with-info; 8+ is real failure.
|
||||
if ($LASTEXITCODE -ge 8) { throw "robocopy failed with exit $LASTEXITCODE" }
|
||||
# Prefer rsync where available (Linux/macOS); fall back to Windows robocopy.
|
||||
# Both perform a mirror: orphan files in the destination are removed so
|
||||
# the share matches the local overrides exactly.
|
||||
if (Get-Command rsync -ErrorAction SilentlyContinue) {
|
||||
$src = ($overridesLocal -replace '\\','/').TrimEnd('/') + '/'
|
||||
$dst = ($shareFiles -replace '\\','/').TrimEnd('/') + '/'
|
||||
if (-not (Test-Path $shareFiles)) { New-Item -ItemType Directory -Path $shareFiles -Force | Out-Null }
|
||||
& rsync -a --delete $src $dst
|
||||
if ($LASTEXITCODE -ne 0) { throw "rsync failed with exit $LASTEXITCODE" }
|
||||
}
|
||||
elseif (Get-Command robocopy -ErrorAction SilentlyContinue) {
|
||||
# /MIR makes destination match source (deletes orphan files in $shareFiles).
|
||||
# /XJ skips junctions, /R:1 /W:1 keeps retry behaviour sane on flaky shares.
|
||||
robocopy $overridesLocal $shareFiles /MIR /XJ /R:1 /W:1 /NFL /NDL /NJH /NJS /NP | Out-Host
|
||||
# Robocopy returns 0-7 for success-with-info; 8+ is real failure.
|
||||
if ($LASTEXITCODE -ge 8) { throw "robocopy failed with exit $LASTEXITCODE" }
|
||||
}
|
||||
else {
|
||||
throw "Neither rsync nor robocopy is available -- can't mirror pack overrides."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user