Skip to content

Commit 16862de

Browse files
committed
feat: include mutagen binary in installer
1 parent 7fc6398 commit 16862de

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

scripts/Publish.ps1

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,29 @@ function Add-CoderSignature([string] $path) {
8383
}
8484
}
8585

86+
function Download-File([string] $url, [string] $outputPath, [string] $etagFile) {
87+
Write-Host "Downloading '$url' to '$outputPath'"
88+
& curl.exe `
89+
--progress-bar `
90+
--show-error `
91+
--fail `
92+
--location `
93+
--etag-compare $etagFile `
94+
--etag-save $etagFile `
95+
--output $outputPath `
96+
$url
97+
if ($LASTEXITCODE -ne 0) { throw "Failed to download $url" }
98+
if (!(Test-Path $outputPath) -or (Get-Item $outputPath).Length -eq 0) {
99+
throw "Failed to download '$url', output file '$outputPath' is missing or empty"
100+
}
101+
}
102+
103+
$goArch = switch ($arch) {
104+
"x64" { "amd64" }
105+
"arm64" { "arm64" }
106+
default { throw "Unsupported architecture: $arch" }
107+
}
108+
86109
# CD to the root of the repo
87110
$repoRoot = Resolve-Path (Join-Path $PSScriptRoot "..")
88111
Push-Location $repoRoot
@@ -145,6 +168,25 @@ if ($null -eq $wintunDllSrc) {
145168
$wintunDllDest = Join-Path $vpnFilesPath "wintun.dll"
146169
Copy-Item $wintunDllSrc $wintunDllDest
147170

171+
# Download the mutagen binary from our bucket for this platform if we don't have
172+
# it yet (or it's different). We use `curl.exe` here because `Invoke-WebRequest`
173+
# is notoriously slow.
174+
$mutagenVersion = "v0.18.1"
175+
$mutagenSrcPath = Join-Path $repoRoot "scripts\files\mutagen-windows-$($goArch).exe"
176+
$mutagenSrcUrl = "https://storage.googleapis.com/coder-desktop/mutagen/$($mutagenVersion)/mutagen-windows-$($goArch).exe"
177+
$mutagenEtagFile = $mutagenSrcPath + ".etag"
178+
Download-File $mutagenSrcUrl $mutagenSrcPath $mutagenEtagFile
179+
$mutagenDestPath = Join-Path $vpnFilesPath "mutagen.exe"
180+
Copy-Item $mutagenSrcPath $mutagenDestPath
181+
182+
# Download mutagen agents tarball.
183+
$mutagenAgentsSrcPath = Join-Path $repoRoot "scripts\files\mutagen-agents.tar.gz"
184+
$mutagenAgentsSrcUrl = "https://storage.googleapis.com/coder-desktop/mutagen/$($mutagenVersion)/mutagen-agents.tar.gz"
185+
$mutagenAgentsEtagFile = $mutagenAgentsSrcPath + ".etag"
186+
Download-File $mutagenAgentsSrcUrl $mutagenAgentsSrcPath $mutagenAgentsEtagFile
187+
$mutagenAgentsDestPath = Join-Path $vpnFilesPath "mutagen-agents.tar.gz"
188+
Copy-Item $mutagenAgentsSrcPath $mutagenAgentsDestPath
189+
148190
# Build the MSI installer
149191
& dotnet.exe run --project .\Installer\Installer.csproj -c Release -- `
150192
build-msi `

scripts/files/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
mutagen-*.tar.gz
2+
mutagen-*.exe
3+
*.etag

0 commit comments

Comments
 (0)