Skip to content
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Prep branch for v14 (#2022)
Co-authored-by: Claude <noreply@anthropic.com>
  • Loading branch information
flanakin and claude authored Feb 24, 2026
commit 1625345f90a02e26528e6ae403d444fd71f4eecd
87 changes: 87 additions & 0 deletions src/scripts/Update-Version.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,93 @@ if ($update -or $Version)
Write-Output " return '$ver'"
Write-Output "}"
} | Out-File "$PSScriptRoot/../PowerShell/Private/Get-VersionNumber.ps1" -Encoding ascii -Append:$false

# Release tag strips prerelease labels and trailing .0 (e.g., "14.0-dev" -> "v14")
$releaseTag = 'v' + (($ver -replace '-.*$', '') -replace '\.0$', '')

# Update changelog with new version section
Write-Verbose "Updating changelog..."
$changelogPath = Join-Path $repoRoot 'docs-mslearn/toolkit/changelog.md'
if (Test-Path $changelogPath)
{
$changelogLines = Get-Content $changelogPath
$anchorIndex = $changelogLines.IndexOf('<br><a name="latest"></a>')
if ($anchorIndex -ge 0)
{
# Find the first ## v heading after the anchor
$prevTag = $null
for ($i = $anchorIndex + 1; $i -lt $changelogLines.Count; $i++)
{
if ($changelogLines[$i] -match '^## v(.+)$')
{
$prevTag = $Matches[1] -replace '\s.*$', ''
break
}
}

$releaseTagName = $releaseTag.TrimStart('v')

# Skip if this version section already exists
if ($prevTag -eq $releaseTagName)
{
Write-Verbose "- Changelog already has v$releaseTagName section"
}
else
{
$releaseDate = (Get-Date).AddMonths(1).ToString('MMMM yyyy')
$newSection = @(
''
"## v$releaseTagName"
''
"_Released ${releaseDate}_"
''
'<!-- prettier-ignore-start -->'
'> [!div class="nextstepaction"]'
"> [Download](https://github.com/microsoft/finops-toolkit/releases/tag/$releaseTag)"
'> [!div class="nextstepaction"]'
"> [Full changelog](https://github.com/microsoft/finops-toolkit/compare/v$prevTag...$releaseTag)"
'<!-- prettier-ignore-end -->'
''
'<br>'
)

$changelogLines = $changelogLines[0..$anchorIndex] + $newSection + $changelogLines[($anchorIndex + 1)..($changelogLines.Count - 1)]
$changelogLines | Out-File $changelogPath -Encoding utf8
Write-Verbose "- Added v$releaseTagName section to changelog"
}
}
}

# Update integration test version variables
Write-Verbose "Updating integration test versions..."
$testPath = Join-Path $repoRoot 'src/powershell/Tests/Integration/Toolkit.Tests.ps1'
if (Test-Path $testPath)
{
$testContent = Get-Content $testPath -Raw
$releaseTagName = $releaseTag.TrimStart('v')

# Extract current planned release and skip if already up to date
if ($testContent -match '\$plannedRelease = ''([^'']+)''')
{
$oldPlanned = $Matches[1]

if ($oldPlanned -eq $releaseTagName)
{
Write-Verbose "- Integration test already has planned release '$releaseTagName'"
}
else
{
# Update $plannedRelease to the new version
$testContent = $testContent -replace '\$plannedRelease = ''[^'']+''', ('$plannedRelease = ''{0}''' -f $releaseTagName)

# Prepend old planned release to $expected array
$testContent = $testContent -replace '\$expected = @\(', ('$expected = @(''{0}'', ' -f $oldPlanned)

$testContent | Out-File $testPath -NoNewline -Encoding utf8
Write-Verbose "- Updated planned release from '$oldPlanned' to '$releaseTagName'"
}
}
}
}

return $ver