Files
poli0981andClaude Opus 5.5 d39f188ea6 ci(release): Velopack to Cloudflare R2, CycloneDX SBOM, SHA256SUMS, Gitea release
GitHub Releases is gone. A v* tag now builds and packs on the Windows runner
as before (scripts/pack.ps1), then `vpk upload s3` puts the packages and the
feed on R2 (releases.poli0981.dev/commandforge, feed last), the ops
publish-r2.yml adds <version>/SHA256SUMS and the SBOM, a Gitea release gets
the notes and the links (no binaries), and the ops announcer posts to
Discord. R2 credentials stay in VPK_* environment variables of this
tag/dispatch-only workflow.

scripts/release-assets.ps1 (also runs locally) writes the CycloneDX SBOM
(CycloneDX tool 6.3.2, replacing GitHub's dependency-graph SBOM, decision
D7), SHA256SUMS of the files this version ships, and the notes from
CHANGELOG.md. The feed files are no longer hashed: vpk rewrites them on
upload, which is what made checksums.txt wrong for RELEASES and
releases.win.json in 2.1.0 and 2.2.0.

A manual run on a branch is a dry run: it builds, packs, reads the previous
release from R2 and keeps the files as an artifact, but uploads nothing.
Attestations go (no OIDC on Gitea). VirusTotal stays optional.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 09:13:13 +07:00

130 lines
6.1 KiB
PowerShell

#requires -Version 7
<#
.SYNOPSIS
Writes the release's SBOM, SHA256SUMS and release notes next to the Velopack output.
.DESCRIPTION
Run after scripts/pack.ps1 (release.yml does; it also runs locally, as a dry run). Produces:
<OutputDir>/versioned/<Version>/sbom.cdx.json CycloneDX SBOM of the solution (test projects
left out; build-only packages listed with
scope "excluded")
<OutputDir>/versioned/<Version>/SHA256SUMS sha256sum format, one line per file below
<OutputDir>/release-notes.md CHANGELOG.md section + download links
release.yml uploads `versioned/` to https://releases.poli0981.dev/commandforge/<Version>/ with the
ops repo's publish-r2.yml, and uses release-notes.md as the Gitea release's body.
SHA256SUMS covers what this version ships: the installer and the portable zip (stable names
at the folder root, replaced by the next release), this version's full and delta packages, and
the SBOM. Not the feed files (releases.win.json, assets.win.json, RELEASES): `vpk upload`
rewrites them on every release, so a checksum of them is stale at the next one.
.PARAMETER Version
SemVer version without the leading 'v', e.g. 2.3.0.
.PARAMETER VirusTotalAnalysis
Optional: the `analysis` output of crazy-max/ghaction-virustotal ("path=url,path=url"). Each
file gets a link to its permanent VirusTotal report in the notes.
.EXAMPLE
./scripts/pack.ps1 -Version 2.3.0; ./scripts/release-assets.ps1 -Version 2.3.0
#>
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[string] $Version,
[string] $ReleasesDir = 'Releases',
[string] $OutputDir = 'r2-release',
[string] $BaseUrl = 'https://releases.poli0981.dev/commandforge',
[string] $VirusTotalAnalysis = ''
)
$ErrorActionPreference = 'Stop'
if ($Version -notmatch '^\d+\.\d+\.\d+$') { throw "Version '$Version' is not X.Y.Z" }
$repoRoot = Split-Path -Parent $PSScriptRoot
Push-Location $repoRoot
try {
$releases = (Resolve-Path -LiteralPath $ReleasesDir).Path
$versioned = Join-Path $OutputDir "versioned/$Version"
New-Item -ItemType Directory -Force -Path $versioned | Out-Null
# --- What this version ships -------------------------------------------------------------
$required = @('CommandForge-win-Setup.exe', 'CommandForge-win-Portable.zip', "CommandForge-$Version-full.nupkg")
foreach ($name in $required) {
if (-not (Test-Path -LiteralPath (Join-Path $releases $name) -PathType Leaf)) {
throw "$ReleasesDir is missing $name (run scripts/pack.ps1 -Version $Version first)"
}
}
# The delta exists only when the previous release was downloaded before packing.
$delta = "CommandForge-$Version-delta.nupkg"
$shipped = @($required) + @(if (Test-Path -LiteralPath (Join-Path $releases $delta)) { $delta })
# --- SBOM (CycloneDX) ----------------------------------------------------------------------
Write-Host "Writing the CycloneDX SBOM..." -ForegroundColor Cyan
dotnet tool run dotnet-CycloneDX CommandForge.slnx `
--exclude-test-projects `
--configuration Release `
--output $versioned `
--filename sbom.cdx.json `
--output-format Json `
--set-name CommandForge `
--set-version $Version
if ($LASTEXITCODE -ne 0) { throw "CycloneDX failed with exit code $LASTEXITCODE" }
$sbom = Join-Path $versioned 'sbom.cdx.json'
# --- SHA256SUMS ----------------------------------------------------------------------------
$files = @($shipped | ForEach-Object { Get-Item -LiteralPath (Join-Path $releases $_) }) + (Get-Item -LiteralPath $sbom)
$lines = $files |
Sort-Object Name |
ForEach-Object { '{0} {1}' -f (Get-FileHash -Algorithm SHA256 -LiteralPath $_.FullName).Hash.ToLowerInvariant(), $_.Name }
# LF line endings, as sha256sum writes and `sha256sum -c` expects.
[IO.File]::WriteAllText((Join-Path $versioned 'SHA256SUMS'), (($lines -join "`n") + "`n"), [Text.Encoding]::ASCII)
$lines | ForEach-Object { Write-Host $_ }
# --- Release notes -------------------------------------------------------------------------
$changelog = (Get-Content CHANGELOG.md -Raw) -replace "`r`n", "`n"
$pattern = "(?ms)^## \[$([regex]::Escape($Version))\][^\n]*\n(.*?)(?=^## \[|^\[[^\]]+\]: |\z)"
$section = [regex]::Match($changelog, $pattern, 'None', [TimeSpan]::FromSeconds(5))
if (-not ($section.Success -and $section.Groups[1].Value.Trim())) {
throw "CHANGELOG.md has no section for $Version"
}
$vbase = "$BaseUrl/$Version"
$notes = [Collections.Generic.List[string]]::new()
$notes.Add($section.Groups[1].Value.Trim())
$notes.AddRange([string[]]@(
'', '## Download (Windows 10/11, x64)', '',
"- Installer: [CommandForge-win-Setup.exe]($BaseUrl/CommandForge-win-Setup.exe)",
"- Portable: [CommandForge-win-Portable.zip]($BaseUrl/CommandForge-win-Portable.zip)",
"- [SHA256SUMS]($vbase/SHA256SUMS) · [SBOM (CycloneDX)]($vbase/sbom.cdx.json)",
'',
'The installer and the portable zip always hold the newest release; the checksums below are this one''s.',
'Installed copies update from the app (More (⋯) → Check for updates). Versions 2.2.0 and older',
'checked GitHub, which is gone: install this version once by hand, over the old one.',
'', '```', ($lines -join "`n"), '```'))
if ($VirusTotalAnalysis) {
$notes.AddRange([string[]]@('', '### VirusTotal', ''))
foreach ($pair in $VirusTotalAnalysis -split ',') {
$file = ($pair -split '=', 2)[0]
if (-not $file) { continue }
$hash = (Get-FileHash -Algorithm SHA256 -LiteralPath $file).Hash.ToLowerInvariant()
$notes.Add(('- [{0}](https://www.virustotal.com/gui/file/{1})' -f (Split-Path $file -Leaf), $hash))
}
}
$notesPath = Join-Path $OutputDir 'release-notes.md'
[IO.File]::WriteAllText($notesPath, (($notes -join "`n") + "`n"), [Text.UTF8Encoding]::new($false))
Write-Host "Release notes: $notesPath" -ForegroundColor Green
}
finally {
Pop-Location
}