chore(release): prepare public source release
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$Tag
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
Set-StrictMode -Version Latest
|
||||
|
||||
function Test-SemVer {
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$Version
|
||||
)
|
||||
|
||||
$match = [regex]::Match(
|
||||
$Version,
|
||||
'^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$'
|
||||
)
|
||||
if (-not $match.Success) {
|
||||
return $false
|
||||
}
|
||||
|
||||
$preRelease = $match.Groups[4].Value
|
||||
return @($preRelease -split '\.' | Where-Object {
|
||||
$_ -match '^0\d+$'
|
||||
}).Count -eq 0
|
||||
}
|
||||
|
||||
$workspaceRoot = Split-Path -Parent $PSScriptRoot
|
||||
$cargoToml = Get-Content -Raw -LiteralPath (Join-Path $workspaceRoot 'Cargo.toml')
|
||||
$match = [regex]::Match($cargoToml, '(?ms)^\[workspace\.package\].*?^version\s*=\s*"([^"]+)"')
|
||||
if (-not $match.Success) {
|
||||
throw 'Could not resolve [workspace.package].version from Cargo.toml.'
|
||||
}
|
||||
|
||||
$version = $match.Groups[1].Value
|
||||
if (-not (Test-SemVer -Version $version)) {
|
||||
throw "Workspace version is not valid SemVer: $version"
|
||||
}
|
||||
|
||||
if ($Tag -ne "v$version") {
|
||||
throw "Tag $Tag does not match workspace version v$version."
|
||||
}
|
||||
|
||||
Write-Host "SemVer release tag verified: $Tag"
|
||||
Reference in New Issue
Block a user