Public/Test-CCReleaseReady.ps1
|
function Test-CCReleaseReady { <# .SYNOPSIS Checks whether a repository is ready to be released, one row per check. Changes nothing in the working tree. .DESCRIPTION Asks, before a tag exists, everything the release workflow will insist on after one does: release.repository It is a git repository. release.remote What the remote has was fetched (skipped with -NoFetch). release.branch The default branch is checked out. release.clean-tree Nothing is uncommitted. release.in-sync Neither ahead of nor behind the remote. release.latest-tag The latest version tag, which is the current version. release.manifests Every manifest states that version: the last release, never the next. release.targets What the release will publish, as .codecompass/config.yml declares it. A Warning when nothing is declared: Test-CCReleaseOutcome then has nothing to ask after the release. release.changelog-current CHANGELOG.md has an entry for that version. release.changelog-unreleased CHANGELOG.md has work under '## [Unreleased]' to release. release.nuget-policy Only where a workflow logs in to NuGet by trusted publishing: when a run of it was last seen to log in. The policy on nuget.org cannot be read from outside, and a release whose login fails has pushed its tag already. A Warning where no run has logged in, with the dry run that makes the test. Never a Fail. A row's Status is Pass, Fail, Warning, Skipped or Info. The repository is ready when no row is Fail. Publish-CCRelease runs these checks itself and stops on a failure. It fetches from the remote unless told not to, so that "in sync" and "the latest tag" are true now and not as of the last fetch. It asks GitHub for the runs of a workflow that logs in to NuGet, with the gh on the path. Nothing else is touched. .PARAMETER NoFetch Do not fetch, and do not ask GitHub. Compare with what was last known of the remote. .EXAMPLE Test-CCReleaseReady .EXAMPLE Test-CCReleaseReady -Path . | Where-Object Status -EQ 'Fail' #> [CmdletBinding()] [OutputType([pscustomobject])] param( [Parameter(Position = 0)] [string]$Path = '.', [switch]$NoFetch ) $full = (Resolve-Path -LiteralPath $Path).Path $results = [CodeCompass.Core.Releases.ReleaseReadiness]::new().Assess($full, -not $NoFetch) $results | ConvertTo-CCCheckRow Get-CCNuGetPolicyRow -Path $full -NoAsk:$NoFetch } |