-
Notifications
You must be signed in to change notification settings - Fork 1
fix(release): synchronize 1.2.3 versions and reject mismatched tags #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| # Dependency-free release gate regression tests; compatible with PowerShell 5.1. | ||
| $ErrorActionPreference = 'Stop' | ||
| Set-StrictMode -Version Latest | ||
| $validator = Join-Path $PSScriptRoot 'verify-release-version.ps1' | ||
| $fixture = Join-Path ([IO.Path]::GetTempPath()) ('browser-cli-version-' + [Guid]::NewGuid().ToString('N')) | ||
| $resolvedFixture = [IO.Path]::GetFullPath($fixture) | ||
| $tempRoot = [IO.Path]::GetFullPath([IO.Path]::GetTempPath()).TrimEnd([IO.Path]::DirectorySeparatorChar) + [IO.Path]::DirectorySeparatorChar | ||
| if (-not $resolvedFixture.StartsWith($tempRoot, [StringComparison]::OrdinalIgnoreCase)) { throw 'Fixture is outside temporary directory' } | ||
| New-Item -ItemType Directory -Path (Join-Path $fixture 'skills/lexmount-browser/scripts') -Force | Out-Null | ||
| $cases = [Collections.Generic.List[string]]::new() | ||
| $utf8 = [Text.UTF8Encoding]::new($false) | ||
|
|
||
| function Write-Fixture([string]$Path, [string]$Text) { | ||
| [IO.File]::WriteAllText((Join-Path $fixture $Path), $Text, $utf8) | ||
| } | ||
| function Reset-Fixture([string]$Version = '1.2.3') { | ||
| Write-Fixture 'Cargo.toml' "[package]`nname = `"lexmount-browser`"`nversion = `"$Version`"`n[dependencies]`nother = `"9.8.7`"`n" | ||
| Write-Fixture 'Cargo.lock' "version = 4`n[[package]]`nname = `"dependency`"`nversion = `"9.8.7`"`n[[package]]`nname = `"lexmount-browser`"`nversion = `"$Version`"`n" | ||
| Write-Fixture 'skills/lexmount-browser/scripts/bootstrap.ps1' ('$version = if ($env:LEXMOUNT_BROWSER_CLI_VERSION) { $env:LEXMOUNT_BROWSER_CLI_VERSION } else { "' + $Version + '" }' + "`n") | ||
| Write-Fixture 'skills/lexmount-browser/scripts/bootstrap.sh' ('version="${LEXMOUNT_BROWSER_CLI_VERSION:-' + $Version + '}"' + "`n") | ||
| } | ||
| function Pass([string]$Name, [scriptblock]$Action) { | ||
| & $Action | ||
| $cases.Add($Name) | ||
| Write-Host "PASS $Name" | ||
| } | ||
| function Reject([string]$Name, [scriptblock]$Action, [string]$Expected) { | ||
| $errorText = $null | ||
| try { & $Action | Out-Null } catch { $errorText = $_.Exception.Message } | ||
| if (-not $errorText -or $errorText -notlike "*$Expected*") { throw "$Name did not reject with '$Expected': $errorText" } | ||
| $cases.Add($Name) | ||
| Write-Host "PASS $Name" | ||
| } | ||
| try { | ||
| Reset-Fixture | ||
| Pass 'matching source and tag' { | ||
| $result = & $validator -RepositoryRoot $fixture -ReleaseTag 'v1.2.3' | ||
| if ($result.Version -cne '1.2.3' -or $result.VerifiedFiles -ne 4) { throw 'Unexpected validation result' } | ||
| } | ||
| Pass 'source-only PR check' { & $validator -RepositoryRoot $fixture | Out-Null } | ||
| foreach ($tag in @('v1.2.2', '1.2.3', 'V1.2.3', 'v1.2.3-extra', '')) { | ||
| Reject "wrong tag [$tag]" { & $validator -RepositoryRoot $fixture -ReleaseTag $tag } 'Release tag' | ||
| } | ||
| Reset-Fixture '1.2.1' | ||
| Reject 'published 1.2.2 incident: every source version still 1.2.1' { & $validator -RepositoryRoot $fixture -ReleaseTag 'v1.2.2' } 'Release tag' | ||
| Reset-Fixture | ||
| Write-Fixture 'Cargo.lock' "[[package]]`nname = `"lexmount-browser`"`nversion = `"1.2.1`"`n" | ||
| Reject 'stale lockfile' { & $validator -RepositoryRoot $fixture } 'Cargo.lock version' | ||
| Reset-Fixture | ||
| Write-Fixture 'skills/lexmount-browser/scripts/bootstrap.ps1' '$version = if ($env:LEXMOUNT_BROWSER_CLI_VERSION) { $env:LEXMOUNT_BROWSER_CLI_VERSION } else { "1.2.1" }' | ||
| Reject 'stale Windows bootstrap' { & $validator -RepositoryRoot $fixture } 'bootstrap.ps1 version' | ||
| Reset-Fixture | ||
| Write-Fixture 'skills/lexmount-browser/scripts/bootstrap.sh' 'version="${LEXMOUNT_BROWSER_CLI_VERSION:-1.2.1}"' | ||
| Reject 'stale Mac bootstrap' { & $validator -RepositoryRoot $fixture } 'bootstrap.sh version' | ||
| Reset-Fixture | ||
| Write-Fixture 'Cargo.lock' "[[package]]`nname = `"some-dependency`"`nversion = `"1.2.3`"`n" | ||
| Reject 'dependency version cannot stand in for package' { & $validator -RepositoryRoot $fixture } 'exactly one lexmount-browser' | ||
| Reset-Fixture | ||
| $lock = [IO.File]::ReadAllText((Join-Path $fixture 'Cargo.lock')) | ||
| Write-Fixture 'Cargo.lock' ($lock + "[[package]]`nname = `"lexmount-browser`"`nversion = `"1.2.3`"`n") | ||
| Reject 'duplicate package' { & $validator -RepositoryRoot $fixture } 'exactly one lexmount-browser' | ||
| Reset-Fixture | ||
| Write-Fixture 'skills/lexmount-browser/scripts/bootstrap.sh' '# version="${LEXMOUNT_BROWSER_CLI_VERSION:-1.2.3}"' | ||
| Reject 'comment is not a bootstrap version' { & $validator -RepositoryRoot $fixture } 'shell bootstrap default' | ||
| Reset-Fixture | ||
| $bootstrap = [IO.File]::ReadAllText((Join-Path $fixture 'skills/lexmount-browser/scripts/bootstrap.sh')) | ||
| Write-Fixture 'skills/lexmount-browser/scripts/bootstrap.sh' ($bootstrap + $bootstrap) | ||
| Reject 'duplicate bootstrap declarations' { & $validator -RepositoryRoot $fixture } 'shell bootstrap default' | ||
| Reset-Fixture '1.2.3-rc.1' | ||
| Pass 'matching prerelease' { & $validator -RepositoryRoot $fixture -ReleaseTag 'v1.2.3-rc.1' | Out-Null } | ||
| Reset-Fixture | ||
| foreach ($path in @('Cargo.toml', 'Cargo.lock', 'skills/lexmount-browser/scripts/bootstrap.ps1', 'skills/lexmount-browser/scripts/bootstrap.sh')) { | ||
| Write-Fixture $path ([IO.File]::ReadAllText((Join-Path $fixture $path)).Replace("`n", "`r`n")) | ||
| } | ||
| Pass 'Windows line endings' { & $validator -RepositoryRoot $fixture -ReleaseTag 'v1.2.3' | Out-Null } | ||
| Pass 'actual repository source' { & $validator | Out-Null } | ||
| Pass 'standalone -File entry point' { | ||
| $currentVersion = (& $validator).Version | ||
| $engine = (Get-Process -Id $PID).Path | ||
| & $engine -NoProfile -NonInteractive -ExecutionPolicy Bypass -File $validator -ReleaseTag "v$currentVersion" | Out-Null | ||
| if ($LASTEXITCODE -ne 0) { throw "Standalone release gate exited $LASTEXITCODE" } | ||
| } | ||
| [pscustomobject]@{ Passed = $cases.Count; Cases = @($cases) } | ConvertTo-Json -Depth 3 | ||
| } finally { | ||
| # Only this invocation's prevalidated GUID fixture, never the temp root. | ||
| Remove-Item -LiteralPath $resolvedFixture -Recurse -Force | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| # Source-only release gate. Never runs bootstrap scripts or changes versions. | ||
| [CmdletBinding()] | ||
| param( | ||
| [string]$RepositoryRoot, | ||
| [AllowEmptyString()][string]$ReleaseTag | ||
| ) | ||
| $ErrorActionPreference = 'Stop' | ||
| Set-StrictMode -Version Latest | ||
| if (-not $PSBoundParameters.ContainsKey('RepositoryRoot')) { | ||
| $RepositoryRoot = Join-Path $PSScriptRoot '../..' | ||
| } | ||
|
|
||
| function Read-OneMatch([string]$Text, [string]$Pattern, [string]$Label) { | ||
| $found = [regex]::Matches($Text, $Pattern) | ||
| if ($found.Count -ne 1) { throw "Expected exactly one $Label; found $($found.Count)" } | ||
| return $found[0].Groups[1].Value | ||
| } | ||
|
|
||
| # These deliberately accept the repository's literal version declarations only. | ||
| # Fail closed if the manifest/bootstrap layout changes; never guess a version | ||
| # from a comment, dependency, environment override or a different package. | ||
| $manifest = Get-Content -LiteralPath (Join-Path $RepositoryRoot 'Cargo.toml') -Raw | ||
| $package = Read-OneMatch $manifest '(?ms)^\[package\][ \t]*\r?\n(.*?)(?=^\[|\z)' 'Cargo.toml [package] section' | ||
| $name = Read-OneMatch $package '(?m)^name[ \t]*=[ \t]*"([^"]+)"[ \t]*\r?$' 'package name' | ||
| if ($name -cne 'lexmount-browser') { throw "Unexpected package name: $name" } | ||
| $version = Read-OneMatch $package '(?m)^version[ \t]*=[ \t]*"([^"]+)"[ \t]*\r?$' 'package version' | ||
| $semver = '(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?' | ||
| if ($version -cnotmatch "^$semver$") { throw "Invalid literal package version: $version" } | ||
|
|
||
| $lock = Get-Content -LiteralPath (Join-Path $RepositoryRoot 'Cargo.lock') -Raw | ||
| $entries = @([regex]::Matches($lock, '(?ms)^\[\[package\]\][ \t]*\r?\n(.*?)(?=^\[|\z)') | | ||
| Where-Object { $_.Groups[1].Value -match '(?m)^name[ \t]*=[ \t]*"lexmount-browser"[ \t]*\r?$' }) | ||
| if ($entries.Count -ne 1) { throw 'Expected exactly one lexmount-browser entry in Cargo.lock' } | ||
| $lockVersion = Read-OneMatch $entries[0].Groups[1].Value '(?m)^version[ \t]*=[ \t]*"([^"]+)"[ \t]*\r?$' 'Cargo.lock package version' | ||
| $psBootstrap = Get-Content -LiteralPath (Join-Path $RepositoryRoot 'skills/lexmount-browser/scripts/bootstrap.ps1') -Raw | ||
| $shBootstrap = Get-Content -LiteralPath (Join-Path $RepositoryRoot 'skills/lexmount-browser/scripts/bootstrap.sh') -Raw | ||
| $psVersion = Read-OneMatch $psBootstrap '(?m)^\$version = if \(\$env:LEXMOUNT_BROWSER_CLI_VERSION\) \{ \$env:LEXMOUNT_BROWSER_CLI_VERSION \} else \{ "([^"]+)" \}[ \t]*\r?$' 'PowerShell bootstrap default' | ||
| $shVersion = Read-OneMatch $shBootstrap '(?m)^version="\$\{LEXMOUNT_BROWSER_CLI_VERSION:-([^}]+)\}"[ \t]*\r?$' 'shell bootstrap default' | ||
| foreach ($entry in @( | ||
| @{ Label = 'Cargo.lock'; Value = $lockVersion }, | ||
| @{ Label = 'bootstrap.ps1'; Value = $psVersion }, | ||
| @{ Label = 'bootstrap.sh'; Value = $shVersion } | ||
| )) { | ||
| if ($entry.Value -cne $version) { throw "$($entry.Label) version $($entry.Value) does not match Cargo.toml $version" } | ||
| } | ||
| if ($PSBoundParameters.ContainsKey('ReleaseTag') -and $ReleaseTag -cne "v$version") { | ||
| throw "Release tag '$ReleaseTag' does not match package/bootstrap version v$version" | ||
| } | ||
| [pscustomobject]@{ Version = $version; ReleaseTag = $ReleaseTag; VerifiedFiles = 4 } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In
build-macos, themacos-14hosted runner is Intel/x86_64, while this command attempts to execute the newly builtaarch64-apple-darwinbinary. Every matching tagged release will therefore fail here with an incompatible-architecture error before signing, packaging, and publishing; use an ARM runner or verify the embedded version without executing the cross-compiled binary.Useful? React with 👍 / 👎.