Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,4 @@ jobs:
export REGISTRY_AUTH_FILE="$RUNNER_TEMP/csrun-auth.json"
trap 'rm -f "$REGISTRY_AUTH_FILE"' EXIT
printf '%s' "$DOCKERHUB_TOKEN" | skopeo login --authfile "$REGISTRY_AUTH_FILE" --username "$DOCKERHUB_USERNAME" --password-stdin docker.io
status=0
for sdk in 10 11 10-11; do
echo "::group::Promote SDK $sdk"
if python tools/release-images.py restore "$sdk" && python tools/release-images.py publish; then
echo "SDK $sdk promotion succeeded."
else
echo "::error::SDK $sdk promotion failed."
status=1
fi
echo "::endgroup::"
done
exit "$status"
python tools/release-images.py publish-all
49 changes: 37 additions & 12 deletions BuildAndPublish.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,27 @@ function Invoke-CsrunDocker([string[]] $Arguments) {
if ($LASTEXITCODE -ne 0) { throw "docker $($Arguments[0]) failed with exit $LASTEXITCODE." }
}

function Resolve-CsrunImageTags([string[]] $ConvenienceTags, [string] $EngineVersion) {
if ($EngineVersion -and $EngineVersion -cnotmatch '^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$') { throw 'Engine release version must use vMAJOR.MINOR.PATCH.' }
$versioned = @(if ($EngineVersion) { $ConvenienceTags | ForEach-Object { "$_-$EngineVersion" } })
$all = @($ConvenienceTags) + $versioned
if (@($all | Where-Object { $_.Length -gt 128 -or $_ -cnotmatch '^[A-Za-z0-9_][A-Za-z0-9_.-]*$' }).Count) { throw 'Invalid or overlong Docker tag.' }
if (@($all | Select-Object -Unique).Count -ne $all.Count) { throw 'Duplicate Docker tags.' }
[pscustomobject]@{ ConvenienceTags=@($ConvenienceTags); VersionedTags=$versioned; Tags=$all }
}

function Get-CsrunPublishedEngine([string] $Repository, [string] $Destination, [string] $EngineVersion) {
if ($Repository -cnotmatch '^[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+$') { throw 'Invalid engine repository.' }
$release = Invoke-RestMethod "https://api.github.com/repos/$Repository/releases/latest"
$asset = @($release.assets | Where-Object name -CEQ 'csrun.ps1')
if ($release.draft -or $release.prerelease -or $release.tag_name -cnotmatch '^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$' -or $asset.Count -ne 1 -or $asset[0].digest -cnotmatch '^sha256:[a-f0-9]{64}$') { throw 'Latest release has no verifiable csrun.ps1 asset.' }
if ($EngineVersion -and $EngineVersion -cne $release.tag_name) { throw 'Explicit engine version differs from the authoritative downloaded release.' }
Invoke-WebRequest "https://github.com/$Repository/releases/latest/download/csrun.ps1" -OutFile $Destination
$hash = (Get-FileHash $Destination -Algorithm SHA256).Hash.ToLowerInvariant()
if ("sha256:$hash" -cne $asset[0].digest -or (Get-Item $Destination).Length -ne $asset[0].size) { throw 'Latest engine asset changed or failed integrity validation.' }
[pscustomobject]@{ Release=$release; Hash=$hash }
}

function BuildAndPublish {
[CmdletBinding(SupportsShouldProcess)]
param(
Expand Down Expand Up @@ -137,11 +158,12 @@ function BuildAndPublish {
if ($version.FullVersion -cnotmatch '^(?:[1-9][0-9]*)\.(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$' -or [version](($version.FullVersion -split '-')[0]) -lt [version]'10.0.0') { throw 'Supply exact .NET 10+ SDK versions.' }
}
$tags = @($publishTags, $majorMinorTags, $majorTags)
if (@($tags | Where-Object { $_.Length -gt 128 -or $_ -cnotmatch '^[A-Za-z0-9_][A-Za-z0-9_.-]*$' }).Count) { throw 'Invalid or overlong Docker tag.' }
$tagPlan = Resolve-CsrunImageTags $tags $EngineVersion
if ($BuildOnly -and $Platform.Count -ne 1) { throw 'BuildOnly loads one architecture at a time; test each explicitly.' }
$image = '{0}/{1}' -f $Repository.TrimEnd('/'), $ImageName
if (@($Platform | Select-Object -Unique).Count -ne $Platform.Count) { throw 'Supply each target platform only once.' }
if ($EnginePath -and $EngineVersion -cnotmatch '^v\d+\.\d+\.\d+$') { throw 'Local engines require an explicit release version.' }
if ($EnginePath -and -not $EngineVersion) { throw 'Local engines require an explicit release version.' }
if ($PSBoundParameters.ContainsKey('EngineVersion') -and -not $EngineVersion) { throw 'Engine release version must not be empty.' }
if (-not $BuildOnly -and $image -ceq 'docker.io/codebeltnet/csrun') {
if ($Platform.Count -ne 2) { throw 'Codebelt production requires both native AMD64 and ARM64 verification.' }
if ($EnginePath -or $EngineRepository -cne 'codebeltnet/csrun' -or $SourceRepository -cne 'https://github.com/codebeltnet/csrun') { throw 'Codebelt production images require the canonical source and verified latest published engine.' }
Expand All @@ -157,11 +179,14 @@ function BuildAndPublish {
MajorMinorTags = $majorMinorTags
PublishTags = $publishTags
BuildArgs = @()
Tags = @($tags | ForEach-Object { "${image}:$_" })
Tags = @($tagPlan.Tags | ForEach-Object { "${image}:$_" })
ConvenienceTags = @($tagPlan.ConvenienceTags | ForEach-Object { "${image}:$_" })
VersionedTags = @($tagPlan.VersionedTags | ForEach-Object { "${image}:$_" })
UnresolvedVersionedTags = @(if (-not $EngineVersion) { $tags | ForEach-Object { "${image}:$_-<verified-release-version>" } })
Platforms = $Platform
DockerContexts = $DockerContext
Builders = $Builder
EngineVersion = $null
EngineVersion = $EngineVersion
EngineSha256 = $null
BaseImage = $null
MetadataFile = [IO.Path]::GetFullPath($MetadataFile)
Expand Down Expand Up @@ -216,18 +241,18 @@ function BuildAndPublish {
$hash = (Get-FileHash $engine -Algorithm SHA256).Hash.ToLowerInvariant()
} else {
# Resolve the moving reference once for all requested platforms.
if ($EngineRepository -cnotmatch '^[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+$') { throw 'Invalid engine repository.' }
$release = Invoke-RestMethod "https://api.github.com/repos/$EngineRepository/releases/latest"
$asset = @($release.assets | Where-Object name -CEQ 'csrun.ps1')
if ($release.draft -or $release.tag_name -cnotmatch '^v\d+\.\d+\.\d+$' -or $asset.Count -ne 1 -or $asset[0].digest -cnotmatch '^sha256:[a-f0-9]{64}$') { throw 'Latest release has no verifiable csrun.ps1 asset.' }
Invoke-WebRequest $engineUrl -OutFile $engine
$hash = (Get-FileHash $engine -Algorithm SHA256).Hash.ToLowerInvariant()
if ("sha256:$hash" -cne $asset[0].digest -or (Get-Item $engine).Length -ne $asset[0].size) { throw 'Latest engine asset changed or failed integrity validation.' }
$publishedEngine = Get-CsrunPublishedEngine $EngineRepository $engine $EngineVersion
$release = $publishedEngine.Release
$hash = $publishedEngine.Hash
}
$tokens = $null; $errors = $null
$ast = [System.Management.Automation.Language.Parser]::ParseFile($engine, [ref]$tokens, [ref]$errors)
if ($errors.Count -or -not $ast.ParamBlock -or 'ManifestJson' -notin $ast.ParamBlock.Parameters.Name.VariablePath.UserPath) { throw 'Downloaded engine is not a valid manifest-capable PowerShell script.' }
$invocation.EngineVersion = $release.tag_name
$tagPlan = Resolve-CsrunImageTags $tags $release.tag_name
$invocation.Tags = @($tagPlan.Tags | ForEach-Object { "${image}:$_" })
$invocation.VersionedTags = @($tagPlan.VersionedTags | ForEach-Object { "${image}:$_" })
$invocation.UnresolvedVersionedTags = @()
$invocation.EngineSha256 = $hash
foreach ($file in @('container-entrypoint.ps1', 'container-build.ps1')) { Copy-Item -LiteralPath (Join-Path $PSScriptRoot $file) -Destination $context }
$revision = & git -C $PSScriptRoot rev-parse HEAD
Expand Down Expand Up @@ -288,7 +313,7 @@ function BuildAndPublish {
$platformArgs = if ($Platform.Count -eq 1) { @('--platform', ($Platform[0] -split '/')[1]) } else { @() }
& python (Join-Path $PSScriptRoot 'tools/oci.py') merge $archiveRoot --version $release.tag_name --revision $revision --engine $hash --source $SourceRepository @platformArgs @archives
if ($LASTEXITCODE -ne 0) { throw 'Cannot assemble native-verified artifacts.' }
& python (Join-Path $PSScriptRoot 'tools/oci.py') publish $archiveRoot --version $release.tag_name --revision $revision --engine $hash --source $SourceRepository @platformArgs --tags @($invocation.Tags)
& python (Join-Path $PSScriptRoot 'tools/oci.py') publish $archiveRoot --version $release.tag_name --revision $revision --engine $hash --source $SourceRepository @platformArgs --tags @($invocation.Tags) --versioned-tags @($invocation.VersionedTags)
if ($LASTEXITCODE -ne 0) { throw 'Registry promotion or inspection failed.' }
$invocation.Published = $true
$invocation | Add-Member RegistryImages (Get-Content "$archiveRoot.published.json" -Raw | ConvertFrom-Json)
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.2.2] - 2026-11-18

This patch release extends Docker publishing with release-versioned SDK aliases alongside the existing movable convenience tags. The standalone native PowerShell engine (`csrun.ps1`), manifest schema version 1 and container execution contract remain unchanged.

### Added

- Added a `-vMAJOR.MINOR.PATCH` alias for every existing SDK environment tag, derived from the verified engine release or explicit validated local-engine version, with separate convenience/versioned `-PassThru` metadata and unresolved offline planning placeholders,
- Added release-versioned destination preflight, matching-digest retries, explicit conflict rejection and exact OCI index digest verification to the shared manual/CI publisher; deployment preflights every SDK variant and verifies all versioned aliases before moving convenience aliases, preserving native checks, attestations, saved release artifacts and stale-release protection without additional builds,
- Added regression coverage and documentation for both tag families, fork publishing and manual recovery, compatibility/version axes, registry concurrency and selective immutability, digest pinning and security-update expectations; historical convenience-only recovery retains its saved aliases without synthesizing historical versioned tags.

## [0.2.1] - 2026-11-16

This patch release cleans disposable container output by skipping a specific .NET SDK first-run workload integrity check, with the verification trade-off and opt-in restoration documented. The standalone native PowerShell engine (`csrun.ps1`) and manifest schema version 1 remain unchanged.
Expand Down Expand Up @@ -48,6 +58,7 @@ This is the first release that introduces csrun as a standalone PowerShell scrip
- Added pull request and tag release workflows that run the test suite on Windows with the .NET 11 SDK and a .NET 10 compatibility job, then create a draft GitHub release with the tested `csrun.ps1` attached,
- Added the MIT license.

[0.2.2]: https://github.com/codebeltnet/csrun/compare/v0.2.1...v0.2.2
[0.2.1]: https://github.com/codebeltnet/csrun/compare/v0.2.0...v0.2.1
[0.2.0]: https://github.com/codebeltnet/csrun/compare/v0.1.0...v0.2.0
[0.1.0]: https://github.com/codebeltnet/csrun/releases/tag/v0.1.0
Loading