Files
gclo/.github/scripts/Update-PackageManifests.ps1
T
james.maesandClaude Fable 5.1 987762295d ci: release through the standards' shared Velopack workflow; publishers fail instead of skip (#77)
## What

Releases now build through the standards' shared `release-velopack.yml`
(standards#5, pinned to `e8ab30f`), which gives SLSA Build L3 provenance
and lets exception EX-0004 close after the first successful run.
`release.yml` keeps only what is gclo's, and every publisher **fails
instead of skipping** when it cannot publish, so a green run means every
channel shipped (#76, part of #62; blocks #67).

- `release.yml`: `verify` (tag on `main`) → `gates` (the full `ci`
workflow, now including the FlaUI suite as a blocking gate since it is a
required check on `main`; the `ui-tests-advisory` input is removed,
closes #54) → `release` (shared workflow: locked restore, Release build,
tests + 100% coverage gate, publish, vpk pack, Syft SBOMs, `SHA256SUMS`,
provenance, draft-then-publish) → caller-side `packages`
(Scoop/Chocolatey manifests PR + `choco push`), `winget`, and opt-in
`nuget`. Publishers run in the `release` environment (created;
deployment rule: tags `v*`) and fail on a missing `DEPS_PAT`,
`CHOCO_API_KEY`, `WINGET_TOKEN`/`WINGET_PACKAGE_ID`, or `NUGET_API_KEY`
when `NUGET_PUBLISH` is `true`. Separate jobs, so a failed publisher
re-runs alone after its token is added.
- **Lock files:** the locked release publish had never run
(`-p:RestoreLockedMode=true` arrived in #68 after the last tag) and
failed locally: `-r win-x64 --self-contained -p:PublishSingleFile=true`
changes every project's restore graph (RID graph;
`Microsoft.NET.ILLink.Tasks` via the single-file analyzer).
`gclo.Engine`, `gclo.ViewModels` and `gclo.Cli` now declare
`RuntimeIdentifiers=win-x64` and `EnableSingleFileAnalyzer=true`, and
the lock files carry both graphs, so the plain locked restore and the
publish agree.
- Asset names follow the shared workflow:
`gclo-cli-win-x64-<version>.zip`, `gclo-<version>.cdx.json`,
`gclo-cli-<version>.cdx.json`; generated release notes replace
`New-ReleaseNotes.ps1` (deleted). `Update-PackageManifests.ps1`,
`bucket/gclo.json` (autoupdate URL) and `PackagingManifestTests` follow;
the tests accept both names because 1.0.0's manifests still point at the
unversioned asset.
- LICENSE ships inside the published app and CLI through the project
files (the shared workflow does not add it).
- Docs: `docs/RELEASING.md` rewritten (required tokens table, rehearsal
prerelease step, per-job recovery), ADR 0007, README "Verifying a
release" (`--signer-repo KofTwentyTwo/standards`), SECURITY.md,
CONTRIBUTING gate table, ADR 0003, threat model T11 + revision row. #7
lists the tokens to add.

## How it was tested

- `dotnet restore gclo.slnx -p:Platform=x64 --locked-mode` passes;
`dotnet build … -warnaserror` 0 warnings; `gclo.Engine.Tests` 422/422
and `gclo.Cli.Tests` 129/129 with 100% line coverage on all three
packages; `dotnet format --verify-no-changes --severity warn` clean;
PSScriptAnalyzer 0 findings; `actionlint` clean on both workflows.
- The shared workflow's exact publish commands pass locked mode locally
and include `LICENSE`:
  ```powershell
dotnet publish gclo.Cli/gclo.Cli.csproj -c Release -r win-x64
--self-contained -p:RestoreLockedMode=true -p:PublishSingleFile=true
dotnet publish gclo/gclo.csproj -c Release -p:Platform=x64 -r win-x64
--self-contained -p:RestoreLockedMode=true -p:WindowsPackageType=None
-p:WindowsAppSDKSelfContained=true -p:PublishTrimmed=false
  ```
- Not yet exercised on a real tag: the shared workflow has never run
(its author asked for gclo's next prerelease to be its first). Per #67
the rehearsal is `v1.0.1-beta.2`, after the `release` environment holds
the tokens listed on #7.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: James Maes <james@kof22.com>
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-09 18:03:21 -05:00

113 lines
4.1 KiB
PowerShell

#Requires -Version 7.4
<#
.SYNOPSIS
Points the Scoop manifest (bucket/gclo.json) and the Chocolatey package
(packaging/chocolatey) at a stable release's CLI zip.
.DESCRIPTION
Both package managers install the same asset, gclo-cli-win-x64-<version>.zip, by URL and
SHA-256. This script rewrites the version, URL, checksum, and release-notes link
in all three files from one source of truth: the version and the zip's hash
(computed from -CliZipPath, or taken from -Sha256). The release workflow runs it
on every stable tag before `choco pack` and opens a PR with the result so the
committed manifests always describe the latest stable release.
.PARAMETER Version
The stable semantic version, e.g. 1.2.3 (no leading 'v').
.PARAMETER CliZipPath
Path to the built gclo-cli-win-x64-<version>.zip to hash. Either this or -Sha256.
.PARAMETER Sha256
The zip's SHA-256 (lowercase hex) when it is already known.
#>
[CmdletBinding()]
param(
[Parameter(Mandatory)]
[ValidatePattern('^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$')]
[string] $Version,
[string] $CliZipPath,
[string] $Sha256
)
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
<#
.SYNOPSIS
Overwrites a text file keeping its encoding (BOM or not) as it was.
#>
function Write-FileText
{
param(
[Parameter(Mandatory)] [string] $Path,
[Parameter(Mandatory)] [string] $Text
)
$bytes = [System.IO.File]::ReadAllBytes($Path)
$hasBom = $bytes.Length -ge 3 -and $bytes[0] -eq 0xEF -and $bytes[1] -eq 0xBB -and $bytes[2] -eq 0xBF
[System.IO.File]::WriteAllText($Path, $Text, [System.Text.UTF8Encoding]::new($hasBom))
}
<#
.SYNOPSIS
Writes a progress line to the information stream (visible in the workflow log).
#>
function Write-Progress-Line
{
param([Parameter(Mandatory)] [string] $Message)
Write-Information -MessageData $Message -InformationAction Continue
}
if(-not $Sha256)
{
if(-not $CliZipPath)
{
throw 'Give -CliZipPath or -Sha256.'
}
$Sha256 = (Get-FileHash -LiteralPath $CliZipPath -Algorithm SHA256).Hash.ToLowerInvariant()
}
if($Sha256 -notmatch '^[0-9a-f]{64}$')
{
throw "'$Sha256' is not a lowercase SHA-256."
}
$repoRoot = Resolve-Path (Join-Path $PSScriptRoot '..\..')
$url = "https://github.com/KofTwentyTwo/gclo/releases/download/v$Version/gclo-cli-win-x64-$Version.zip"
################################################################################
## Scoop: a real JSON edit, so the file stays valid whatever its layout. ##
################################################################################
$scoopPath = Join-Path $repoRoot 'bucket\gclo.json'
$scoop = Get-Content -LiteralPath $scoopPath -Raw | ConvertFrom-Json
$scoop.version = $Version
$scoop.architecture.'64bit'.url = $url
$scoop.architecture.'64bit'.hash = $Sha256
$scoopJson = ($scoop | ConvertTo-Json -Depth 10) -replace '\\u0026', '&'
Write-FileText -Path $scoopPath -Text ($scoopJson + "`n")
Write-Progress-Line "Scoop manifest -> $Version"
################################################################################
## Chocolatey: nuspec version + release notes link, install script URL + hash. ##
################################################################################
$nuspecPath = Join-Path $repoRoot 'packaging\chocolatey\gclo.nuspec'
$nuspec = Get-Content -LiteralPath $nuspecPath -Raw
$nuspec = $nuspec -replace '<version>[^<]+</version>', "<version>$Version</version>"
$nuspec = $nuspec -replace '<releaseNotes>[^<]+</releaseNotes>', "<releaseNotes>https://github.com/KofTwentyTwo/gclo/releases/tag/v$Version</releaseNotes>"
Write-FileText -Path $nuspecPath -Text $nuspec
$installPath = Join-Path $repoRoot 'packaging\chocolatey\tools\chocolateyinstall.ps1'
$install = Get-Content -LiteralPath $installPath -Raw
$install = $install -replace "url64bit\s*=\s*'[^']+'", "url64bit = '$url'"
$install = $install -replace "checksum64\s*=\s*'[^']+'", "checksum64 = '$Sha256'"
Write-FileText -Path $installPath -Text $install
Write-Progress-Line "Chocolatey package -> $Version"
if($env:GITHUB_OUTPUT)
{
Add-Content -Path $env:GITHUB_OUTPUT -Value "sha256=$Sha256"
}