fix(CLI-39): bump Contracts nupkg to 0.2.0; scope pack-clients.ps1 regexes
Code review of the CLI-39 branch caught an Important gap: Contracts.csproj was left at the already-published 0.1.2 while the .NET Client moved to 0.2.0. Invoke-PackDotnet in scripts/pack-clients.ps1 packs and publishes both ZB.MOM.WW.MxGateway.Contracts and .Client through the same -Publish loop, and the new collision guard runs every nupkg it finds through Assert-GiteaPackageNotPublished. Left as-is, the next real .NET publish would pack Contracts at 0.1.2, the guard would correctly refuse to republish it, and the loop would abort mid-way with Client (alphabetically first) possibly already pushed -- the two packages permanently out of lockstep. - src/ZB.MOM.WW.MxGateway.Contracts/ZB.MOM.WW.MxGateway.Contracts.csproj: <Version> 0.1.2 -> 0.2.0, matching the .NET Client (they have always released together). - src/Directory.Build.props: corrected a comment that was now stale -- it claimed the repo-wide 0.1.2 default was kept to match the Contracts package, which is no longer true now that Contracts.csproj overrides it. The <Version> value itself is unchanged; Server/Worker/Tests staying at 0.1.2 is a separate, not-yet-made decision, out of scope for CLI-39. - docs/ClientPackaging.md: Contracts.csproj added as a fifth manifest in the Versioning section, with the near-miss recorded. Also hardened scripts/pack-clients.ps1 per the same review: the Python (pyproject.toml) and Rust (Cargo.toml) version-extraction regexes now scope to the [project]/[package] section header instead of matching the first "version = ..." line anywhere in the file (Cargo.toml has an identical second one under [workspace.package] -- matching whichever came first was luck of ordering, not correctness). One-line comment added on the nuget filename-parse regex. Verified live against the real Gitea registry: Contracts and Client both still refuse at 0.1.2 and both now pass at 0.2.0, including running the actual Invoke-PackDotnet filename-parse-then-guard logic against two freshly packed real .nupkg files. dotnet build of Contracts.csproj and the client slnx both clean. No publish performed.
This commit is contained in:
@@ -185,6 +185,9 @@ function Invoke-PackDotnet {
|
||||
if ($Publish) {
|
||||
Write-Host 'Publishing .NET packages to Gitea...' -ForegroundColor Yellow
|
||||
Get-ChildItem $OutputDir -Filter 'ZB.MOM.WW.MxGateway.*.nupkg' | ForEach-Object {
|
||||
# nupkg filenames are '<PackageId>.<Version>.nupkg'; the id itself contains
|
||||
# dots (e.g. 'ZB.MOM.WW.MxGateway.Client'), so the id capture is lazy and the
|
||||
# version capture anchors on the leading digit to split at the right dot.
|
||||
$fileBaseName = [System.IO.Path]::GetFileNameWithoutExtension($_.Name)
|
||||
if ($fileBaseName -notmatch '^(?<id>.+?)\.(?<version>\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?)$') {
|
||||
throw "Could not parse a NuGet package id/version out of '$($_.Name)'."
|
||||
@@ -231,7 +234,14 @@ function Invoke-PackPython {
|
||||
if ($Publish) {
|
||||
$pyprojectPath = Join-Path $RepoRoot 'clients/python/pyproject.toml'
|
||||
$pyprojectContent = Get-Content $pyprojectPath -Raw
|
||||
if ($pyprojectContent -notmatch '(?m)^\s*version\s*=\s*"([^"]+)"') {
|
||||
# Scope to the [project] section (not just the first "version = ..." line
|
||||
# in the file) — [build-system]/[tool.*] sections can carry their own
|
||||
# version-shaped keys, and matching the file's first hit would be luck
|
||||
# of ordering, not correctness.
|
||||
if ($pyprojectContent -notmatch '(?ms)^\[project\](?<section>.*?)(?=^\[|\z)') {
|
||||
throw "Could not find a [project] section in '$pyprojectPath'."
|
||||
}
|
||||
if ($Matches.section -notmatch '(?m)^\s*version\s*=\s*"([^"]+)"') {
|
||||
throw "Could not find [project].version in '$pyprojectPath'."
|
||||
}
|
||||
Assert-GiteaPackageNotPublished -Type 'pypi' -Name 'zb-mom-ww-mxaccess-gateway-client' -Version $Matches[1]
|
||||
@@ -285,7 +295,14 @@ function Invoke-PackRust {
|
||||
if ($Publish) {
|
||||
$cargoTomlPath = Join-Path $rustDir 'Cargo.toml'
|
||||
$cargoTomlContent = Get-Content $cargoTomlPath -Raw
|
||||
if ($cargoTomlContent -notmatch '(?m)^\s*version\s*=\s*"([^"]+)"') {
|
||||
# Scope to the [package] section specifically — Cargo.toml also carries a
|
||||
# [workspace.package] section with its own "version = ..." line (today
|
||||
# identical, by convention, not by anything this regex can rely on), and
|
||||
# matching whichever comes first in the file is luck of ordering.
|
||||
if ($cargoTomlContent -notmatch '(?ms)^\[package\](?<section>.*?)(?=^\[|\z)') {
|
||||
throw "Could not find a [package] section in '$cargoTomlPath'."
|
||||
}
|
||||
if ($Matches.section -notmatch '(?m)^\s*version\s*=\s*"([^"]+)"') {
|
||||
throw "Could not find [package] version in '$cargoTomlPath'."
|
||||
}
|
||||
Assert-GiteaPackageNotPublished -Type 'cargo' -Name 'zb-mom-ww-mxgateway-client' -Version $Matches[1]
|
||||
|
||||
Reference in New Issue
Block a user