Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 34 additions & 24 deletions .pipelines/templates/release-upload-buildinfo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ jobs:
$dateTime = [datetime]::new($dateTime.Ticks - ($dateTime.Ticks % [timespan]::TicksPerSecond), $dateTime.Kind)

$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.
$stableRelease = $metadata.StableRelease.PublishToChannels
$ltsRelease = $metadata.LTSRelease.PublishToChannels

Expand All @@ -65,40 +68,44 @@ jobs:

$buildInfo = $buildInfoJsonContent | ConvertFrom-Json
$buildInfo.ReleaseDate = $dateTime
$currentReleaseTag = $buildInfo.ReleaseTag -Replace 'v',''

$targetFile = "$ENV:PIPELINE_WORKSPACE/$fileName"
ConvertTo-Json -InputObject $buildInfo | Out-File $targetFile -Encoding ascii

if ($stableRelease -or $fileName -eq "preview.json") {
Set-BuildVariable -Name CopyMainBuildInfo -Value YES
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
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.

## 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
Comment on lines +86 to +87
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.
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
}

$versionFile = "$ENV:PIPELINE_WORKSPACE/$($semVersion.Major)-$($semVersion.Minor).json"
Copy-Item -Path $targetFile -Destination $versionFile -Force
Set-BuildVariable -Name VersionBuildInfoJsonFile -Value $versionFile
Set-BuildVariable -Name CopyVersionBuildInfo -Value YES
} else {
Set-BuildVariable -Name CopyVersionBuildInfo -Value NO
Set-BuildVariable -Name UploadStable -Value NO
}
displayName: Create json files

Expand All @@ -116,24 +123,27 @@ jobs:

$storageContext = New-AzStorageContext -StorageAccountName $storageAccount -UseConnectedAccount

if ($env:CopyMainBuildInfo -eq 'YES') {
$jsonFile = "$env:BuildInfoJsonFile"
#preview
if ($env:UploadPreview -eq 'YES') {
$jsonFile = "$env:PreviewBuildInfoFile"
$blobName = Get-Item $jsonFile | Split-Path -Leaf
Write-Verbose -Verbose "Uploading $jsonFile to $containerName/$prefix/$blobName"
Set-AzStorageBlobContent -File $jsonFile -Container $containerName -Blob "$prefix/$blobName" -Context $storageContext -Force
}

if ($env:CopyLTSBuildInfo -eq 'YES') {
$jsonFile = "$env:LtsBuildInfoJsonFile"
#LTS
if ($env:UploadLTS -eq 'YES') {
$jsonFile = "$env:LTSBuildInfoFile"
$blobName = Get-Item $jsonFile | Split-Path -Leaf
Write-Verbose -Verbose "Uploading $jsonFile to $containerName/$prefix/$blobName"
Set-AzStorageBlobContent -File $jsonFile -Container $containerName -Blob "$prefix/$blobName" -Context $storageContext -Force
}

if ($env:CopyVersionBuildInfo -eq 'YES') {
$jsonFile = "$env:VersionBuildInfoJsonFile"
#stable
if ($env:UploadStable -eq 'YES') {
$jsonFile = "$env:StableBuildInfoFile"
$blobName = Get-Item $jsonFile | Split-Path -Leaf
Write-Verbose -Verbose "Uploading $jsonFile to $containerName/$prefix/$blobName"
Set-AzStorageBlobContent -File $jsonFile -Container $containerName -Blob "$prefix/$blobName" -Context $storageContext -Force
}
condition: and(succeeded(), eq(variables['CopyMainBuildInfo'], 'YES'))
condition: and(succeeded(), or(eq(variables['UploadPreview'], 'YES'), eq(variables['UploadLTS'], 'YES'), eq(variables['UploadStable'], 'YES')))
Loading