Skip to content
Merged
Show file tree
Hide file tree
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
29 changes: 29 additions & 0 deletions scripts/release/init_hotfix_broker.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
param(
[Parameter(Mandatory=$true)][string]$brokerVersion,
[Parameter(Mandatory=$true)][string]$CommonVersion
)

# Get the path of the current script
$scriptPath = $PSScriptRoot

# Get all PS1 files in a specific folder
$filesToInclude = Get-ChildItem -Path "$scriptPath/libs" -Filter "*.ps1" -Recurse

# Dot-source each file
foreach ($file in $filesToInclude) {
. $file.FullName
}

$brokerRCVersion = "$brokerVersion-RC1"
$broker4jRCVersion = "$brokerVersion-RC1" # Same as brokerVersion

# Move to root folder. (android complete)

# Update BROKER and BROKER4J version
Write-Host "New broker version: '$brokerRCVersion' and broker4j version: '$broker4jRCVersion' ." -ForegroundColor Green
Update-ChangelogHeaderForHotfix -changelogFile $BROKER_CHANGELOG_FILE -newVersion $brokerRCVersion -changelogConstants $changelogConstants -newCommonVersion $CommonVersion

Update-VersionNumber -versioningFile $BROKER_VERSIONING_FILE -newVersion $brokerRCVersion
Update-VersionNumber -versioningFile $BROKER4j_VERSIONING_FILE -newVersion $broker4jRCVersion

Update-GradeFile -gradleFile $BROKER_BUILD_GRADLE_FILE -variableToUpdate $GRADLE_BROKER4J_VAR -newVersion $broker4jRCVersion
57 changes: 57 additions & 0 deletions scripts/release/init_hotfix_for_all.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
param(
[Parameter(Mandatory=$true)][string]$msalVersion,
[Parameter(Mandatory=$true)][string]$brokerVersion,
[Parameter(Mandatory=$true)][string]$CommonVersion
)


# Get the path of the current script
$scriptPath = $PSScriptRoot

# Get all PS1 files in a specific folder
$filesToInclude = Get-ChildItem -Path "$scriptPath/libs" -Filter "*.ps1" -Recurse

# Dot-source each file
foreach ($file in $filesToInclude) {
. $file.FullName
}


$msalRCVersion = "$msalVersion-RC1"
$brokerRCVersion = "$brokerVersion-RC1"
$CommonRCVersion = "$CommonVersion-RC1"
$Common4jRCVersion = "$CommonVersion-RC1" # Same as CommonVersion
$broker4jRCVersion = "$brokerVersion-RC1" # Same as brokerVersion

# Move to root folder. (android complete)

# Update COMMON and COMMON4J version
Write-Host "New common version: '$commonRCVersion' and common4j version: '$common4jRCVersion' ." -ForegroundColor Green
Update-ChangelogHeaderForCommonHotfix -changelogFile $COMMON_CHANGELOG_FILE -newVersion $commonRCVersion -changelogConstants $changelogConstants

Update-VersionNumber -versioningFile $COMMON4J_VERSIONING_FILE -newVersion $common4jRCVersion
Update-VersionNumber -versioningFile $COMMON_VERSIONING_FILE -newVersion $commonRCVersion

Update-GradeFile -gradleFile $COMMON_BUILD_GRADLE_FILE -variableToUpdate $GRADLE_COMMON4J_VAR -newVersion $common4jRCVersion

# Update MSAL version
Write-Host "New msal version: '$msalRCVersion'." -ForegroundColor Green
Update-ChangelogHeaderForHotfix -changelogFile $MSAL_CHANGELOG_FILE -newVersion $msalRCVersion -changelogConstants $changelogConstants -newCommonVersion $commonRCVersion

Update-VersionNumber -versioningFile $MSAL_VERSIONING_FILE -newVersion $msalRCVersion

Update-GradeFile -gradleFile $MSAL_BUILD_GRADLE_FILE -variableToUpdate $GRADLE_COMMON4J_VAR -newVersion $common4jRCVersion
Update-GradeFile -gradleFile $MSAL_BUILD_GRADLE_FILE -variableToUpdate $GRADLE_COMMON_VAR -newVersion $commonRCVersion

# Update BROKER and BROKER4J version
Write-Host "New broker version: '$brokerRCVersion' and broker4j version: '$broker4jRCVersion' ." -ForegroundColor Green
Update-ChangelogHeaderForHotfix -changelogFile $BROKER_CHANGELOG_FILE -newVersion $brokerRCVersion -changelogConstants $changelogConstants -newCommonVersion $commonRCVersion

Update-VersionNumber -versioningFile $BROKER_VERSIONING_FILE -newVersion $brokerRCVersion
Update-VersionNumber -versioningFile $BROKER4j_VERSIONING_FILE -newVersion $broker4jRCVersion

Update-GradeFile -gradleFile $BROKER4J_BUILD_GRADLE_FILE -variableToUpdate $GRADLE_COMMON4J_VAR -newVersion $common4JRCVersion

Update-GradeFile -gradleFile $BROKER_BUILD_GRADLE_FILE -variableToUpdate $GRADLE_COMMON_VAR -newVersion $commonRCVersion
Update-GradeFile -gradleFile $BROKER_BUILD_GRADLE_FILE -variableToUpdate $GRADLE_BROKER4J_VAR -newVersion $broker4jRCVersion
Update-GradeFile -gradleFile $BROKER_BUILD_GRADLE_FILE -variableToUpdate $GRADLE_COMMON4J_VAR -newVersion $common4JRCVersion
25 changes: 25 additions & 0 deletions scripts/release/init_hotfix_msal.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
param(
[Parameter(Mandatory=$true)][string]$msalVersion,
[Parameter(Mandatory=$true)][string]$CommonVersion
)

# Get the path of the current script
$scriptPath = $PSScriptRoot

# Get all PS1 files in a specific folder
$filesToInclude = Get-ChildItem -Path "$scriptPath/libs" -Filter "*.ps1" -Recurse

# Dot-source each file
foreach ($file in $filesToInclude) {
. $file.FullName
}

$msalRCVersion = "$msalVersion-RC1"

# Move to root folder. (android complete)

# Update MSAL version
Write-Host "New msal version: '$msalRCVersion'." -ForegroundColor Green
Update-ChangelogHeaderForHotfix -changelogFile $MSAL_CHANGELOG_FILE -newVersion $msalRCVersion -changelogConstants $changelogConstants -newCommonVersion $CommonVersion

Update-VersionNumber -versioningFile $MSAL_VERSIONING_FILE -newVersion $msalRCVersion
92 changes: 92 additions & 0 deletions scripts/release/libs/helper_methods.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,98 @@ function Update-ChangelogHeader {
}
}

function Update-ChangelogHeaderForHotfix {
param(
[Hashtable]$changelogConstants,
[string]$newVersion,
[string]$newCommonVersion = "",
[string]$changelogFile
)

if (-not (Test-Path $changelogFile -PathType Leaf)) {
Write-Host "Input file '$changelogFile' not found." -ForegroundColor Red
return
}

# Read the content of the file
$fileContent = Get-Content -Path $changelogFile -Raw

# Create the new version header with the version number
$newVersionHeader = "Version $newVersion"

# Create the entry content
$entryContent = "- [PATCH] Update common @$newCommonVersion"

# Complete new section with proper newlines
$newSection = "$newVersionHeader`r`n$($changelogConstants["separator"])`r`n$entryContent`r`n`r`n"

# Find the first version section pattern (Version X.X.X followed by separator) - only match the FIRST occurrence
$versionPattern = "(?m)^Version \d+\.\d+\.\d+"

if ($fileContent -match $versionPattern) {
# Get the position of the first match
$match = [regex]::Match($fileContent, $versionPattern)
if ($match.Success) {
# Insert the new section before the first existing version
$beforeMatch = $fileContent.Substring(0, $match.Index)
$afterMatch = $fileContent.Substring($match.Index)
$newContent = $beforeMatch + $newSection + $afterMatch

# Write the updated content back to the file
Set-Content -Path $changelogFile -Value $newContent -NoNewline

Write-Host "$changelogFile updated successfully with hotfix version $newVersion."
}
}
else {
Write-Host "Could not find existing version pattern in $changelogFile. File format may be different than expected." -ForegroundColor Red
}
}

function Update-ChangelogHeaderForCommonHotfix {
param(
[Hashtable]$changelogConstants,
[string]$newVersion,
[string]$changelogFile
)

if (-not (Test-Path $changelogFile -PathType Leaf)) {
Write-Host "Input file '$changelogFile' not found." -ForegroundColor Red
return
}

# Read the content of the file
$fileContent = Get-Content -Path $changelogFile -Raw

# Create the new version header with no entries (header only)
$newVersionHeader = "Version $newVersion"

# Complete new section (just header and separator, no entries)
$newSection = "$newVersionHeader`r`n$($changelogConstants["separator"])`r`n`r`n"

# Find the first version section pattern and insert above it
$versionPattern = "(?m)^Version \d+\.\d+\.\d+"

if ($fileContent -match $versionPattern) {
# Get the position of the first match
$match = [regex]::Match($fileContent, $versionPattern)
if ($match.Success) {
# Insert the new section before the first existing version
$beforeMatch = $fileContent.Substring(0, $match.Index)
$afterMatch = $fileContent.Substring($match.Index)
$newContent = $beforeMatch + $newSection + $afterMatch

# Write the updated content back to the file
Set-Content -Path $changelogFile -Value $newContent -NoNewline

Write-Host "$changelogFile updated successfully with hotfix version $newVersion (inserted above existing versions)."
}
}
else {
Write-Host "Could not find existing version pattern in $changelogFile. File format may be different than expected." -ForegroundColor Red
}
}

function Update-GradeFile {
param(
[string]$newVersion,
Expand Down
47 changes: 31 additions & 16 deletions scripts/release/update_rc.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
param(
[Parameter(Mandatory=$true)][UInt32]$rc
[Parameter(Mandatory=$true)][UInt32]$rc,
[Parameter(Mandatory=$false)][switch]$skipCommon,
[Parameter(Mandatory=$false)][switch]$skipMsal,
[Parameter(Mandatory=$false)][switch]$skipBroker
)

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

Write-Host "Update common and common4j." -ForegroundColor Green
Update-AllRCVersionsInFile -newRCVersion $rc -filePath $COMMON4J_VERSIONING_FILE
Update-AllRCVersionsInFile -newRCVersion $rc -filePath $COMMON_VERSIONING_FILE
Update-AllRCVersionsInFile -newRCVersion $rc -filePath $COMMON_BUILD_GRADLE_FILE
Update-AllRCVersionsInFile -newRCVersion $rc -filePath $COMMON_CHANGELOG_FILE
if (-not $skipCommon) {
Write-Host "Update common and common4j." -ForegroundColor Green
Update-AllRCVersionsInFile -newRCVersion $rc -filePath $COMMON4J_VERSIONING_FILE
Update-AllRCVersionsInFile -newRCVersion $rc -filePath $COMMON_VERSIONING_FILE
Update-AllRCVersionsInFile -newRCVersion $rc -filePath $COMMON_BUILD_GRADLE_FILE
Update-AllRCVersionsInFile -newRCVersion $rc -filePath $COMMON_CHANGELOG_FILE
} else {
Write-Host "Skipping common and common4j RC update." -ForegroundColor Yellow
}

Write-Host "Update msal." -ForegroundColor Green
Update-AllRCVersionsInFile -newRCVersion $rc -filePath $MSAL_VERSIONING_FILE
Update-AllRCVersionsInFile -newRCVersion $rc -filePath $MSAL_BUILD_GRADLE_FILE
Update-AllRCVersionsInFile -newRCVersion $rc -filePath $MSAL_CHANGELOG_FILE
if (-not $skipMsal) {
Write-Host "Update msal." -ForegroundColor Green
Update-AllRCVersionsInFile -newRCVersion $rc -filePath $MSAL_VERSIONING_FILE
Update-AllRCVersionsInFile -newRCVersion $rc -filePath $MSAL_BUILD_GRADLE_FILE
Update-AllRCVersionsInFile -newRCVersion $rc -filePath $MSAL_CHANGELOG_FILE
} else {
Write-Host "Skipping msal RC update." -ForegroundColor Yellow
}

Write-Host "Update broker and broker4j." -ForegroundColor Green
Update-AllRCVersionsInFile -newRCVersion $rc -filePath $BROKER_VERSIONING_FILE
Update-AllRCVersionsInFile -newRCVersion $rc -filePath $BROKER4j_VERSIONING_FILE
Update-AllRCVersionsInFile -newRCVersion $rc -filePath $BROKER_BUILD_GRADLE_FILE
Update-AllRCVersionsInFile -newRCVersion $rc -filePath $BROKER4J_BUILD_GRADLE_FILE
Update-AllRCVersionsInFile -newRCVersion $rc -filePath $BROKER_CHANGELOG_FILE
if (-not $skipBroker) {
Write-Host "Update broker and broker4j." -ForegroundColor Green
Update-AllRCVersionsInFile -newRCVersion $rc -filePath $BROKER_VERSIONING_FILE
Update-AllRCVersionsInFile -newRCVersion $rc -filePath $BROKER4j_VERSIONING_FILE
Update-AllRCVersionsInFile -newRCVersion $rc -filePath $BROKER_BUILD_GRADLE_FILE
Update-AllRCVersionsInFile -newRCVersion $rc -filePath $BROKER4J_BUILD_GRADLE_FILE
Update-AllRCVersionsInFile -newRCVersion $rc -filePath $BROKER_CHANGELOG_FILE
} else {
Write-Host "Skipping broker and broker4j RC update." -ForegroundColor Yellow
}
Loading