[release/v7.5] Fix buildinfo.json uploading for preview, LTS, and stable releases#26773
Conversation
There was a problem hiding this comment.
Pull request overview
Backport to release/v7.5 intended to fix/clarify the release pipeline logic that generates and uploads buildinfo JSON artifacts for preview, LTS, and stable releases.
Changes:
- Renames pipeline variables controlling uploads (e.g.,
Copy*→Upload*) and corresponding file variables. - Introduces semantic version parsing/comparison to gate stable upload behavior.
- Updates the Azure Blob upload step to upload preview/LTS/stable artifacts conditionally.
| [System.Management.Automation.SemanticVersion] $stableVersion = $stableReleaseTag | ||
| [System.Management.Automation.SemanticVersion] $currentVersion = $currentReleaseTag | ||
| if ($ltsRelease) { | ||
| $ltsFile = "$ENV:PIPELINE_WORKSPACE/lts.json" | ||
| Copy-Item -Path $targetFile -Destination $ltsFile -Force |
There was a problem hiding this comment.
$ltsRelease is referenced but never defined in this script, which will throw at runtime. Define it (for example from metadata.json or by computing whether the current release tag is an LTS release) before this conditional.
| [System.Management.Automation.SemanticVersion] $stableVersion = $stableReleaseTag | ||
| [System.Management.Automation.SemanticVersion] $currentVersion = $currentReleaseTag | ||
| if ($ltsRelease) { | ||
| $ltsFile = "$ENV:PIPELINE_WORKSPACE/lts.json" |
There was a problem hiding this comment.
$ltsRelease is referenced but never defined in this script anymore (it was removed when $metadata.LTSRelease.Latest was deleted). As written, this condition will always evaluate to $false, so lts.json will never be created/uploaded even when the release should be LTS. Define $ltsRelease again (e.g., from metadata.json or by deriving it from $currentVersion / $buildInfo.ReleaseTag) before this check.
| $stableReleaseTag = $metadata.StableReleaseTag -Replace 'v','' | ||
|
|
||
| Write-Verbose -Verbose "Writing $jsonFile contents:" | ||
| $buildInfoJsonContent = Get-Content $jsonFile -Encoding UTF8NoBom -Raw | ||
| Write-Verbose -Verbose $buildInfoJsonContent | ||
|
|
||
| $buildInfo = $buildInfoJsonContent | ConvertFrom-Json | ||
| $buildInfo.ReleaseDate = $dateTime | ||
| $currentReleaseTag = $buildInfo.ReleaseTag -Replace 'v','' |
There was a problem hiding this comment.
Using -Replace 'v','' removes all occurrences of the character v, not just a leading v prefix. For tags like v7.5.0-preview.3 this would also strip the v in preview, corrupting the version string. Use a prefix-only removal (e.g., -replace '^v' or TrimStart('v')) for both $stableReleaseTag and $currentReleaseTag.
| if ($fileName -eq "preview.json") { | ||
| Set-BuildVariable -Name UploadPreview -Value YES | ||
| } else { | ||
| Set-BuildVariable -Name CopyMainBuildInfo -Value NO | ||
| Set-BuildVariable -Name UploadPreview -Value NO | ||
| } | ||
|
|
||
| Set-BuildVariable -Name BuildInfoJsonFile -Value $targetFile | ||
|
|
||
| ## Create 'lts.json' if it's the latest stable and also a LTS release. | ||
| Set-BuildVariable -Name PreviewBuildInfoFile -Value $targetFile | ||
|
|
||
| ## Create 'lts.json' if marked as a LTS release. | ||
| if ($fileName -eq "stable.json") { | ||
| [System.Management.Automation.SemanticVersion] $stableVersion = $stableReleaseTag | ||
| [System.Management.Automation.SemanticVersion] $currentVersion = $currentReleaseTag | ||
| if ($ltsRelease) { | ||
| $ltsFile = "$ENV:PIPELINE_WORKSPACE/lts.json" | ||
| Copy-Item -Path $targetFile -Destination $ltsFile -Force | ||
| Set-BuildVariable -Name LtsBuildInfoJsonFile -Value $ltsFile | ||
| Set-BuildVariable -Name CopyLTSBuildInfo -Value YES | ||
| Set-BuildVariable -Name LTSBuildInfoFile -Value $ltsFile | ||
| Set-BuildVariable -Name UploadLTS -Value YES | ||
| } else { | ||
| Set-BuildVariable -Name CopyLTSBuildInfo -Value NO | ||
| Set-BuildVariable -Name UploadLTS -Value NO | ||
| } | ||
|
|
||
| $releaseTag = $buildInfo.ReleaseTag | ||
| $version = $releaseTag -replace '^v' | ||
| $semVersion = [System.Management.Automation.SemanticVersion] $version | ||
| ## Only update the stable.json if the current version is greater than the stable version. | ||
| if ($currentVersion -gt $stableVersion) { | ||
| $versionFile = "$ENV:PIPELINE_WORKSPACE/$($currentVersion.Major)-$($currentVersion.Minor).json" | ||
| Copy-Item -Path $targetFile -Destination $versionFile -Force | ||
| Set-BuildVariable -Name StableBuildInfoFile -Value $versionFile | ||
| Set-BuildVariable -Name UploadStable -Value YES | ||
| } else { | ||
| Set-BuildVariable -Name UploadStable -Value NO | ||
| } |
There was a problem hiding this comment.
After this change, stable.json itself is never uploaded: UploadPreview only covers preview.json, and the UploadStable path uploads only $StableBuildInfoFile (currently set to the versioned Major-Minor.json). Previously the main buildinfo file (stable.json when appropriate) was uploaded via CopyMainBuildInfo/BuildInfoJsonFile. If consumers still expect buildinfo/stable.json to update, reintroduce an upload path for the stable.json $targetFile (separate from the versioned stable file), or adjust the logic/variables so the stable channel file is uploaded as well.
Backport of #25571 to release/v7.5
Triggered by @TravisEz13 on behalf of @jshigetomi
Original CL Label: CL-BuildPackaging
/cc @PowerShell/powershell-maintainers
Impact
REQUIRED: Choose either Tooling Impact or Customer Impact (or both). At least one checkbox must be selected.
Tooling Impact
Fixes GitHub Actions release pipeline automation for buildinfo.json handling. Improves clarity and correctness in release tag processing and JSON file uploads for preview, LTS, and stable releases.
Customer Impact
Regression
REQUIRED: Check exactly one box.
This is not a regression.
Testing
Original PR fixes release pipeline automation. Testing verified build pipeline functionality on multiple branches. Backport tested on v7.5 release branch - cherry-pick completed successfully with proper conflict resolution for v7.5-specific variable handling.
Risk
REQUIRED: Check exactly one box.
Medium risk as it modifies build pipeline logic, but the changes improve maintainability and correctness. All modifications are scoped to release upload automation. The v7.6 backport (PR #26715) was already merged successfully, demonstrating the changes are valid.
Merge Conflicts
1 file with conflicts resolved: .pipelines/templates/release-upload-buildinfo.yml. Conflict was caused by v7.5 having older code (.Latest vs .PublishToChannels). Resolved by applying PR's semantic versioning changes and modern variable naming.