-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.ps1
More file actions
37 lines (28 loc) · 1.27 KB
/
Copy pathbuild.ps1
File metadata and controls
37 lines (28 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
$ErrorActionPreference = 'Stop'
$Image = 'hmip-eufy-mower-plugin'
$Tag = '1.1.2'
$Platform = 'linux/arm64'
$Out = "$Image-$Tag.tar"
$OutGz = "$Out.gz"
Write-Host '>> Ensuring buildx builder exists'
docker buildx inspect hcubuild *> $null
if ($LASTEXITCODE -ne 0) {
docker buildx create --name hcubuild --use | Out-Null
} else {
docker buildx use hcubuild | Out-Null
}
Write-Host ">> Building ${Image}:${Tag} for $Platform"
docker buildx build --platform $Platform --tag "${Image}:${Tag}" --load .
if ($LASTEXITCODE -ne 0) { throw 'docker buildx build failed' }
Write-Host ">> Saving image to $Out"
docker save "${Image}:${Tag}" -o $Out
Write-Host ">> Compressing to $OutGz"
if (Test-Path $OutGz) { Remove-Item $OutGz -Force }
Add-Type -AssemblyName System.IO.Compression.FileSystem
$in = [System.IO.File]::OpenRead((Resolve-Path $Out))
$outFs = [System.IO.File]::Create((Join-Path (Get-Location) $OutGz))
$gz = New-Object System.IO.Compression.GZipStream($outFs, [System.IO.Compression.CompressionLevel]::Optimal)
try { $in.CopyTo($gz) } finally { $gz.Dispose(); $outFs.Dispose(); $in.Dispose() }
Remove-Item $Out -Force
Write-Host ">> Done: $(Resolve-Path $OutGz)"
Write-Host ' Upload this file in HCUweb -> Plugins -> Install from file.'