Skip to content

Commit 717aad1

Browse files
authored
Add hotfix initialization scripts and update changelog functions, Fixes AB#3352511 (#380)
This pull request adds new PowerShell scripts to automate hotfix initialization for different components and enhances the release workflow with more flexible version bumping and changelog updates. The main improvements are the introduction of hotfix initialization scripts for MSAL, Broker, and all components, new helper methods for changelog header updates, and the ability to selectively skip RC version updates for specific components. ### Hotfix Initialization Scripts * Added three new scripts: `init_hotfix_msal.ps1`, `init_hotfix_broker.ps1`, and `init_hotfix_for_all.ps1`, which automate the process of preparing hotfix releases for MSAL, Broker, and all components respectively. These scripts update changelogs, version files, and Gradle files to reflect new hotfix versions. [[1]](diffhunk://#diff-908ed34962b66977cfb7947882c1a5e4c28597a4f40fb0bb0fe158743337fdfbR1-R25) [[2]](diffhunk://#diff-91b46a802ffb5f0f8da4c058bfad0e4a410eb72061665b13a86ad4fcc9270d20R1-R29) [[3]](diffhunk://#diff-cb19ed98a231f55368d645c0d7629c1aa0e88d2c3203d05d8bb1c6b52d9284b4R1-R57) ### Changelog Update Helpers * Added two new helper functions in `helper_methods.ps1`: `Update-ChangelogHeaderForHotfix` and `Update-ChangelogHeaderForCommonHotfix`. These functions insert new hotfix version headers into changelog files, either with a patch entry or as a header-only section, improving changelog consistency and automation. ### Flexible RC Version Updates * Enhanced `update_rc.ps1` to accept new parameters (`skipCommon`, `skipMsal`, `skipBroker`) that allow selectively skipping RC version updates for Common, MSAL, or Broker components, increasing control over the release process. [[1]](diffhunk://#diff-dc92c168be3884b522f393430ad248f8cb2ae31f052ecfdb54da388b7a876731L2-R5) [[2]](diffhunk://#diff-dc92c168be3884b522f393430ad248f8cb2ae31f052ecfdb54da388b7a876731R19-R47) [AB#3352511](https://identitydivision.visualstudio.com/fac9d424-53d2-45c0-91b5-ef6ba7a6bf26/_workitems/edit/3352511)
1 parent 0f03083 commit 717aad1

File tree

5 files changed

+234
-16
lines changed

5 files changed

+234
-16
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
param(
2+
[Parameter(Mandatory=$true)][string]$brokerVersion,
3+
[Parameter(Mandatory=$true)][string]$CommonVersion
4+
)
5+
6+
# Get the path of the current script
7+
$scriptPath = $PSScriptRoot
8+
9+
# Get all PS1 files in a specific folder
10+
$filesToInclude = Get-ChildItem -Path "$scriptPath/libs" -Filter "*.ps1" -Recurse
11+
12+
# Dot-source each file
13+
foreach ($file in $filesToInclude) {
14+
. $file.FullName
15+
}
16+
17+
$brokerRCVersion = "$brokerVersion-RC1"
18+
$broker4jRCVersion = "$brokerVersion-RC1" # Same as brokerVersion
19+
20+
# Move to root folder. (android complete)
21+
22+
# Update BROKER and BROKER4J version
23+
Write-Host "New broker version: '$brokerRCVersion' and broker4j version: '$broker4jRCVersion' ." -ForegroundColor Green
24+
Update-ChangelogHeaderForHotfix -changelogFile $BROKER_CHANGELOG_FILE -newVersion $brokerRCVersion -changelogConstants $changelogConstants -newCommonVersion $CommonVersion
25+
26+
Update-VersionNumber -versioningFile $BROKER_VERSIONING_FILE -newVersion $brokerRCVersion
27+
Update-VersionNumber -versioningFile $BROKER4j_VERSIONING_FILE -newVersion $broker4jRCVersion
28+
29+
Update-GradeFile -gradleFile $BROKER_BUILD_GRADLE_FILE -variableToUpdate $GRADLE_BROKER4J_VAR -newVersion $broker4jRCVersion
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
param(
2+
[Parameter(Mandatory=$true)][string]$msalVersion,
3+
[Parameter(Mandatory=$true)][string]$brokerVersion,
4+
[Parameter(Mandatory=$true)][string]$CommonVersion
5+
)
6+
7+
8+
# Get the path of the current script
9+
$scriptPath = $PSScriptRoot
10+
11+
# Get all PS1 files in a specific folder
12+
$filesToInclude = Get-ChildItem -Path "$scriptPath/libs" -Filter "*.ps1" -Recurse
13+
14+
# Dot-source each file
15+
foreach ($file in $filesToInclude) {
16+
. $file.FullName
17+
}
18+
19+
20+
$msalRCVersion = "$msalVersion-RC1"
21+
$brokerRCVersion = "$brokerVersion-RC1"
22+
$CommonRCVersion = "$CommonVersion-RC1"
23+
$Common4jRCVersion = "$CommonVersion-RC1" # Same as CommonVersion
24+
$broker4jRCVersion = "$brokerVersion-RC1" # Same as brokerVersion
25+
26+
# Move to root folder. (android complete)
27+
28+
# Update COMMON and COMMON4J version
29+
Write-Host "New common version: '$commonRCVersion' and common4j version: '$common4jRCVersion' ." -ForegroundColor Green
30+
Update-ChangelogHeaderForCommonHotfix -changelogFile $COMMON_CHANGELOG_FILE -newVersion $commonRCVersion -changelogConstants $changelogConstants
31+
32+
Update-VersionNumber -versioningFile $COMMON4J_VERSIONING_FILE -newVersion $common4jRCVersion
33+
Update-VersionNumber -versioningFile $COMMON_VERSIONING_FILE -newVersion $commonRCVersion
34+
35+
Update-GradeFile -gradleFile $COMMON_BUILD_GRADLE_FILE -variableToUpdate $GRADLE_COMMON4J_VAR -newVersion $common4jRCVersion
36+
37+
# Update MSAL version
38+
Write-Host "New msal version: '$msalRCVersion'." -ForegroundColor Green
39+
Update-ChangelogHeaderForHotfix -changelogFile $MSAL_CHANGELOG_FILE -newVersion $msalRCVersion -changelogConstants $changelogConstants -newCommonVersion $commonRCVersion
40+
41+
Update-VersionNumber -versioningFile $MSAL_VERSIONING_FILE -newVersion $msalRCVersion
42+
43+
Update-GradeFile -gradleFile $MSAL_BUILD_GRADLE_FILE -variableToUpdate $GRADLE_COMMON4J_VAR -newVersion $common4jRCVersion
44+
Update-GradeFile -gradleFile $MSAL_BUILD_GRADLE_FILE -variableToUpdate $GRADLE_COMMON_VAR -newVersion $commonRCVersion
45+
46+
# Update BROKER and BROKER4J version
47+
Write-Host "New broker version: '$brokerRCVersion' and broker4j version: '$broker4jRCVersion' ." -ForegroundColor Green
48+
Update-ChangelogHeaderForHotfix -changelogFile $BROKER_CHANGELOG_FILE -newVersion $brokerRCVersion -changelogConstants $changelogConstants -newCommonVersion $commonRCVersion
49+
50+
Update-VersionNumber -versioningFile $BROKER_VERSIONING_FILE -newVersion $brokerRCVersion
51+
Update-VersionNumber -versioningFile $BROKER4j_VERSIONING_FILE -newVersion $broker4jRCVersion
52+
53+
Update-GradeFile -gradleFile $BROKER4J_BUILD_GRADLE_FILE -variableToUpdate $GRADLE_COMMON4J_VAR -newVersion $common4JRCVersion
54+
55+
Update-GradeFile -gradleFile $BROKER_BUILD_GRADLE_FILE -variableToUpdate $GRADLE_COMMON_VAR -newVersion $commonRCVersion
56+
Update-GradeFile -gradleFile $BROKER_BUILD_GRADLE_FILE -variableToUpdate $GRADLE_BROKER4J_VAR -newVersion $broker4jRCVersion
57+
Update-GradeFile -gradleFile $BROKER_BUILD_GRADLE_FILE -variableToUpdate $GRADLE_COMMON4J_VAR -newVersion $common4JRCVersion
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
param(
2+
[Parameter(Mandatory=$true)][string]$msalVersion,
3+
[Parameter(Mandatory=$true)][string]$CommonVersion
4+
)
5+
6+
# Get the path of the current script
7+
$scriptPath = $PSScriptRoot
8+
9+
# Get all PS1 files in a specific folder
10+
$filesToInclude = Get-ChildItem -Path "$scriptPath/libs" -Filter "*.ps1" -Recurse
11+
12+
# Dot-source each file
13+
foreach ($file in $filesToInclude) {
14+
. $file.FullName
15+
}
16+
17+
$msalRCVersion = "$msalVersion-RC1"
18+
19+
# Move to root folder. (android complete)
20+
21+
# Update MSAL version
22+
Write-Host "New msal version: '$msalRCVersion'." -ForegroundColor Green
23+
Update-ChangelogHeaderForHotfix -changelogFile $MSAL_CHANGELOG_FILE -newVersion $msalRCVersion -changelogConstants $changelogConstants -newCommonVersion $CommonVersion
24+
25+
Update-VersionNumber -versioningFile $MSAL_VERSIONING_FILE -newVersion $msalRCVersion

scripts/release/libs/helper_methods.ps1

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,98 @@ function Update-ChangelogHeader {
9090
}
9191
}
9292

93+
function Update-ChangelogHeaderForHotfix {
94+
param(
95+
[Hashtable]$changelogConstants,
96+
[string]$newVersion,
97+
[string]$newCommonVersion = "",
98+
[string]$changelogFile
99+
)
100+
101+
if (-not (Test-Path $changelogFile -PathType Leaf)) {
102+
Write-Host "Input file '$changelogFile' not found." -ForegroundColor Red
103+
return
104+
}
105+
106+
# Read the content of the file
107+
$fileContent = Get-Content -Path $changelogFile -Raw
108+
109+
# Create the new version header with the version number
110+
$newVersionHeader = "Version $newVersion"
111+
112+
# Create the entry content
113+
$entryContent = "- [PATCH] Update common @$newCommonVersion"
114+
115+
# Complete new section with proper newlines
116+
$newSection = "$newVersionHeader`r`n$($changelogConstants["separator"])`r`n$entryContent`r`n`r`n"
117+
118+
# Find the first version section pattern (Version X.X.X followed by separator) - only match the FIRST occurrence
119+
$versionPattern = "(?m)^Version \d+\.\d+\.\d+"
120+
121+
if ($fileContent -match $versionPattern) {
122+
# Get the position of the first match
123+
$match = [regex]::Match($fileContent, $versionPattern)
124+
if ($match.Success) {
125+
# Insert the new section before the first existing version
126+
$beforeMatch = $fileContent.Substring(0, $match.Index)
127+
$afterMatch = $fileContent.Substring($match.Index)
128+
$newContent = $beforeMatch + $newSection + $afterMatch
129+
130+
# Write the updated content back to the file
131+
Set-Content -Path $changelogFile -Value $newContent -NoNewline
132+
133+
Write-Host "$changelogFile updated successfully with hotfix version $newVersion."
134+
}
135+
}
136+
else {
137+
Write-Host "Could not find existing version pattern in $changelogFile. File format may be different than expected." -ForegroundColor Red
138+
}
139+
}
140+
141+
function Update-ChangelogHeaderForCommonHotfix {
142+
param(
143+
[Hashtable]$changelogConstants,
144+
[string]$newVersion,
145+
[string]$changelogFile
146+
)
147+
148+
if (-not (Test-Path $changelogFile -PathType Leaf)) {
149+
Write-Host "Input file '$changelogFile' not found." -ForegroundColor Red
150+
return
151+
}
152+
153+
# Read the content of the file
154+
$fileContent = Get-Content -Path $changelogFile -Raw
155+
156+
# Create the new version header with no entries (header only)
157+
$newVersionHeader = "Version $newVersion"
158+
159+
# Complete new section (just header and separator, no entries)
160+
$newSection = "$newVersionHeader`r`n$($changelogConstants["separator"])`r`n`r`n"
161+
162+
# Find the first version section pattern and insert above it
163+
$versionPattern = "(?m)^Version \d+\.\d+\.\d+"
164+
165+
if ($fileContent -match $versionPattern) {
166+
# Get the position of the first match
167+
$match = [regex]::Match($fileContent, $versionPattern)
168+
if ($match.Success) {
169+
# Insert the new section before the first existing version
170+
$beforeMatch = $fileContent.Substring(0, $match.Index)
171+
$afterMatch = $fileContent.Substring($match.Index)
172+
$newContent = $beforeMatch + $newSection + $afterMatch
173+
174+
# Write the updated content back to the file
175+
Set-Content -Path $changelogFile -Value $newContent -NoNewline
176+
177+
Write-Host "$changelogFile updated successfully with hotfix version $newVersion (inserted above existing versions)."
178+
}
179+
}
180+
else {
181+
Write-Host "Could not find existing version pattern in $changelogFile. File format may be different than expected." -ForegroundColor Red
182+
}
183+
}
184+
93185
function Update-GradeFile {
94186
param(
95187
[string]$newVersion,

scripts/release/update_rc.ps1

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
param(
2-
[Parameter(Mandatory=$true)][UInt32]$rc
2+
[Parameter(Mandatory=$true)][UInt32]$rc,
3+
[Parameter(Mandatory=$false)][switch]$skipCommon,
4+
[Parameter(Mandatory=$false)][switch]$skipMsal,
5+
[Parameter(Mandatory=$false)][switch]$skipBroker
36
)
47

58
# Get the path of the current script
@@ -13,20 +16,32 @@ foreach ($file in $filesToInclude) {
1316
. $file.FullName
1417
}
1518

16-
Write-Host "Update common and common4j." -ForegroundColor Green
17-
Update-AllRCVersionsInFile -newRCVersion $rc -filePath $COMMON4J_VERSIONING_FILE
18-
Update-AllRCVersionsInFile -newRCVersion $rc -filePath $COMMON_VERSIONING_FILE
19-
Update-AllRCVersionsInFile -newRCVersion $rc -filePath $COMMON_BUILD_GRADLE_FILE
20-
Update-AllRCVersionsInFile -newRCVersion $rc -filePath $COMMON_CHANGELOG_FILE
19+
if (-not $skipCommon) {
20+
Write-Host "Update common and common4j." -ForegroundColor Green
21+
Update-AllRCVersionsInFile -newRCVersion $rc -filePath $COMMON4J_VERSIONING_FILE
22+
Update-AllRCVersionsInFile -newRCVersion $rc -filePath $COMMON_VERSIONING_FILE
23+
Update-AllRCVersionsInFile -newRCVersion $rc -filePath $COMMON_BUILD_GRADLE_FILE
24+
Update-AllRCVersionsInFile -newRCVersion $rc -filePath $COMMON_CHANGELOG_FILE
25+
} else {
26+
Write-Host "Skipping common and common4j RC update." -ForegroundColor Yellow
27+
}
2128

22-
Write-Host "Update msal." -ForegroundColor Green
23-
Update-AllRCVersionsInFile -newRCVersion $rc -filePath $MSAL_VERSIONING_FILE
24-
Update-AllRCVersionsInFile -newRCVersion $rc -filePath $MSAL_BUILD_GRADLE_FILE
25-
Update-AllRCVersionsInFile -newRCVersion $rc -filePath $MSAL_CHANGELOG_FILE
29+
if (-not $skipMsal) {
30+
Write-Host "Update msal." -ForegroundColor Green
31+
Update-AllRCVersionsInFile -newRCVersion $rc -filePath $MSAL_VERSIONING_FILE
32+
Update-AllRCVersionsInFile -newRCVersion $rc -filePath $MSAL_BUILD_GRADLE_FILE
33+
Update-AllRCVersionsInFile -newRCVersion $rc -filePath $MSAL_CHANGELOG_FILE
34+
} else {
35+
Write-Host "Skipping msal RC update." -ForegroundColor Yellow
36+
}
2637

27-
Write-Host "Update broker and broker4j." -ForegroundColor Green
28-
Update-AllRCVersionsInFile -newRCVersion $rc -filePath $BROKER_VERSIONING_FILE
29-
Update-AllRCVersionsInFile -newRCVersion $rc -filePath $BROKER4j_VERSIONING_FILE
30-
Update-AllRCVersionsInFile -newRCVersion $rc -filePath $BROKER_BUILD_GRADLE_FILE
31-
Update-AllRCVersionsInFile -newRCVersion $rc -filePath $BROKER4J_BUILD_GRADLE_FILE
32-
Update-AllRCVersionsInFile -newRCVersion $rc -filePath $BROKER_CHANGELOG_FILE
38+
if (-not $skipBroker) {
39+
Write-Host "Update broker and broker4j." -ForegroundColor Green
40+
Update-AllRCVersionsInFile -newRCVersion $rc -filePath $BROKER_VERSIONING_FILE
41+
Update-AllRCVersionsInFile -newRCVersion $rc -filePath $BROKER4j_VERSIONING_FILE
42+
Update-AllRCVersionsInFile -newRCVersion $rc -filePath $BROKER_BUILD_GRADLE_FILE
43+
Update-AllRCVersionsInFile -newRCVersion $rc -filePath $BROKER4J_BUILD_GRADLE_FILE
44+
Update-AllRCVersionsInFile -newRCVersion $rc -filePath $BROKER_CHANGELOG_FILE
45+
} else {
46+
Write-Host "Skipping broker and broker4j RC update." -ForegroundColor Yellow
47+
}

0 commit comments

Comments
 (0)