Skip to content

[release/v7.6] Fix buildinfo.json uploading for preview, LTS, and stable releases#26715

Merged
daxian-dbw merged 1 commit intoPowerShell:release/v7.6from
daxian-dbw:backport/release/v7.6/25571-0931a75d3
Jan 21, 2026
Merged

[release/v7.6] Fix buildinfo.json uploading for preview, LTS, and stable releases#26715
daxian-dbw merged 1 commit intoPowerShell:release/v7.6from
daxian-dbw:backport/release/v7.6/25571-0931a75d3

Conversation

@daxian-dbw
Copy link
Member

Backport of #25571 to release/v7.6

Triggered by @daxian-dbw 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

  • Required tooling change
  • Optional tooling change (include reasoning)

This fix is required for the release pipeline to correctly upload buildinfo.json files for preview, LTS, and stable releases. It improves the logic for determining which JSON files should be uploaded based on release type and semantic version comparison.

Customer Impact

  • Customer reported
  • Found internally

Regression

REQUIRED: Check exactly one box.

  • Yes
  • No

This is not a regression.

Testing

Verified that buildinfo.json is correctly uploaded for preview, LTS, and stable releases. The changes refactor variable names for clarity and improve semantic version handling to ensure JSON files are only uploaded when appropriate.

Risk

REQUIRED: Check exactly one box.

  • High
  • Medium
  • Low

This is a refinement of release pipeline logic with improved variable naming and conditional checks. The changes are isolated to the build info upload template and do not affect runtime PowerShell functionality.

@daxian-dbw daxian-dbw requested review from a team and jshigetomi as code owners January 21, 2026 20:03
Copilot AI review requested due to automatic review settings January 21, 2026 20:03
@daxian-dbw daxian-dbw added the CL-BuildPackaging Indicates that a PR should be marked as a build or packaging change in the Change Log label Jan 21, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR backports a fix from #25571 to the release/v7.6 branch that improves buildinfo.json uploading logic for preview, LTS, and stable releases. The changes refactor variable names for better clarity and add semantic version comparison to ensure build info files are only uploaded when appropriate.

Changes:

  • Improved variable naming from generic names (CopyMainBuildInfo, BuildInfoJsonFile) to more specific names (UploadPreview, PreviewBuildInfoFile, UploadLTS, UploadStable)
  • Added semantic version comparison to only upload stable.json when the current version is greater than the existing stable version
  • Updated the upload task condition to check all three upload flags (preview, LTS, stable) instead of just one

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

$metadata = Get-Content -LiteralPath "$toolsDirectory/metadata.json" -ErrorAction Stop | ConvertFrom-Json
$stableReleaseTag = $metadata.StableReleaseTag -Replace 'v',''

$currentReleaseTag = $buildInfo.ReleaseTag -Replace 'v',''
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable $buildInfo is used on line 61 before it's defined. The $buildInfo object is not created until line 69 with $buildInfo = $buildInfoJsonContent | ConvertFrom-Json. This will cause a runtime error when the script tries to access $buildInfo.ReleaseTag on a null or undefined variable.

This line should be removed as line 71 correctly sets $currentReleaseTag after $buildInfo is defined.

Suggested change
$currentReleaseTag = $buildInfo.ReleaseTag -Replace 'v',''

Copilot uses AI. Check for mistakes.
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
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PreviewBuildInfoFile variable is set to $targetFile for all file types (preview.json, stable.json, etc.), not just for preview.json files. This variable name suggests it should only contain the preview build info file path, but it's being set regardless of the file type.

Consider either:

  1. Renaming this variable to something more generic like BuildInfoFile since it's used for all types, or
  2. Only setting it when $fileName -eq "preview.json" (move it inside the if block on line 76)

Copilot uses AI. Check for mistakes.
Comment on lines +86 to +87
[System.Management.Automation.SemanticVersion] $stableVersion = $stableReleaseTag
[System.Management.Automation.SemanticVersion] $currentVersion = $currentReleaseTag
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The $stableVersion and $currentVersion semantic version variables are only initialized within the if ($fileName -eq "stable.json") block (lines 86-87), but $stableReleaseTag and $currentReleaseTag are extracted earlier at lines 59 and 71.

The semantic version parsing should happen closer to where the variables are first extracted (after line 71), or the string variables should be extracted just before they're parsed into semantic versions (before line 86). The current approach creates two separate locations where similar logic is applied, which could lead to maintenance issues.

Copilot uses AI. Check for mistakes.
@daxian-dbw daxian-dbw merged commit e29b66e into PowerShell:release/v7.6 Jan 21, 2026
41 checks passed
@daxian-dbw daxian-dbw deleted the backport/release/v7.6/25571-0931a75d3 branch January 21, 2026 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-BuildPackaging Indicates that a PR should be marked as a build or packaging change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants