<# .SYNOPSIS Publish the already-built production image to the registry. .DESCRIPTION Never rebuilds. If the push fails, fix access or connectivity and run this again; the image is already on disk. `docker login` first, with a token that has package-write access. #> [CmdletBinding()] param() Set-StrictMode -Version Latest $ErrorActionPreference = 'Stop' . "$PSScriptRoot/_common.ps1" $Image = Setting IMAGE -Required $Branch = Setting BRANCH 'production' Push-Location $root try { $commit = git rev-parse --verify "$Branch^{commit}" Assert-Ok 'resolve production commit' $sha = (git rev-parse --short $commit.Trim()).Trim() Assert-Ok 'resolve image tag' $tagged = "${Image}:${sha}" $latest = "${Image}:latest" docker image inspect $tagged --format '{{.Id}}' | Out-Null Assert-Ok "find local $tagged (run step 2 first)" # latest must name this candidate, even if another image was built since. docker tag $tagged $latest Assert-Ok 'tag latest image' docker push $tagged Assert-Ok 'push commit image' docker push $latest Assert-Ok 'push latest image' Write-Host "Published $tagged and $latest" } finally { Pop-Location }