Files
chuan 732c43d288
Release / Prepare release (push) Successful in 6s
Release / Build release assets (push) Failing after 7s
feat: sync history on switch to prevent fragmented or lost records
2026-06-05 17:33:32 +08:00

51 lines
1.1 KiB
PowerShell

param(
[string]$Version = "",
[string]$Image = "docker.pchuan.top/cdxs",
[string]$Dockerfile = "Dockerfile",
[string]$Platform = "linux/amd64",
[switch]$NoCache
)
$ErrorActionPreference = "Stop"
$repoRoot = Resolve-Path (Join-Path $PSScriptRoot "..")
Set-Location $repoRoot
if (-not $Version) {
$cargoToml = Get-Content -Raw -Path "Cargo.toml"
if ($cargoToml -notmatch '(?m)^version\s*=\s*"([^"]+)"') {
throw "Cannot read package version from Cargo.toml"
}
$Version = $Matches[1]
}
$versionTag = "${Image}:${Version}"
$latestTag = "${Image}:latest"
Write-Host "Building and pushing Docker image for $Platform"
Write-Host "Tags:"
Write-Host " $versionTag"
Write-Host " $latestTag"
$buildArgs = @(
"buildx", "build",
"--platform", $Platform,
"-f", $Dockerfile,
"-t", $versionTag,
"-t", $latestTag,
"--push"
)
if ($NoCache) {
$buildArgs += "--no-cache"
}
$buildArgs += "."
docker @buildArgs
if ($LASTEXITCODE -ne 0) {
throw "Docker buildx push failed"
}
Write-Host "Pushed $versionTag and $latestTag"