Skip to content

Commit 309523c

Browse files
authored
[ReleaseTools] Add a script for RC mail generation (Azure#23607)
* Script for mail generation * Update gen-mail.ps1 * Update gen-mail.ps1
1 parent 0a29537 commit 309523c

File tree

1 file changed

+190
-0
lines changed

1 file changed

+190
-0
lines changed

tools/ReleaseTools/gen-mail.ps1

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
param (
2+
[Parameter(Mandatory = $true)]
3+
[ValidateSet('RC1','RC2','RC3','Publish')]
4+
[System.String]$Phase,
5+
6+
[Parameter(Mandatory = $true)]
7+
[System.String]$ReleaseBranch,
8+
9+
[Parameter()]
10+
[System.String]$OutFilePath = "mail.md",
11+
12+
[Parameter(Mandatory = $true)]
13+
[System.String]$StorageResourceGroup,
14+
15+
[Parameter(Mandatory = $true)]
16+
[System.String]$StorageAccountName,
17+
18+
[Parameter(Mandatory = $true)]
19+
[System.String]$StorageContianerName,
20+
)
21+
22+
function GetCommitNumber
23+
{
24+
param(
25+
[Parameter(Mandatory = $true)]
26+
[AllowEmptyString()]
27+
[System.String]$pkgName
28+
)
29+
if(-not $pkgName){
30+
return 0
31+
}
32+
$elements = $pkgName -split {$_ -eq "." -or $_ -eq "-"}
33+
[int]$commitNum = [int]$elements[-3]
34+
35+
return $commitNum
36+
}
37+
38+
if ($Phase -ne 'Pulish')
39+
{
40+
Write-Host "Generating $Phase email"
41+
42+
# Changelog
43+
$changelog = Invoke-WebRequest -Uri https://raw.githubusercontent.com/Azure/azure-powershell/internal/release/ChangeLog.md
44+
$changelog = [regex]::split($changelog, "##\s\d+\.\d+\.\d+\s-\s\w+\s\d{4}")[1] -replace '^\s*\n|\n\s*$', ''
45+
46+
## TODO: add thanks list
47+
48+
# Get bumped version and previous version
49+
# Calculate 1st GA modules and preview modules
50+
$BumpedAzPreviewOutFile = "AzPreview_bumped.psd1"
51+
$PreviousAzPreviewOutFile = "AzPreview_previous.psd1"
52+
Invoke-WebRequest -Uri https://raw.githubusercontent.com/Azure/azure-powershell/internal/release/tools/AzPreview/AzPreview.psd1 -OutFile AzPreview_bumped.psd1
53+
$BumpedModuleInfos = Import-PowerShellDataFile -Path $BumpedAzPreviewOutFile
54+
Invoke-WebRequest -Uri https://raw.githubusercontent.com/Azure/azure-powershell/$ReleaseBranch/tools/AzPreview/AzPreview.psd1 -OutFile AzPreview_previous.psd1
55+
$PreviousModuleInfos = Import-PowerShellDataFile -Path $PreviousAzPreviewOutFile
56+
57+
$AzVersion = $BumpedModuleInfos.ModuleVersion
58+
59+
# Get link from storage account
60+
$storageContext = (Get-AzStorageAccount -Name $StorageAccountName -ResourceGroupName $StorageResourceGroup).Context
61+
# $null = Set-AzCurrentStorageAccount -context $storageContext.Context
62+
$PkgList = Get-AzStorageBlob -Container $StorageContianerName -blob Az-Cmdlets-$AzVersion* -Context $storageContext.Context
63+
$x64Msi = ""
64+
$x86Msi = ""
65+
$previewZip = ""
66+
$tarGz = ""
67+
foreach($pkg in $PkgList){
68+
$commitNum = GetCommitNumber $pkg.Name
69+
if ($pkg.Name.EndsWith("x64.msi")){
70+
if ($commitNum -gt (GetCommitNumber $x64Msi)){
71+
$x64Msi = $pkg.Name
72+
}
73+
}
74+
elseif ($pkg.Name.EndsWith("x86.msi")){
75+
if ($commitNum -gt (GetCommitNumber $x86Msi)){
76+
$x86Msi = $pkg.Name
77+
}
78+
}
79+
elseif ($pkg.Name.EndsWith("preview.zip")){
80+
if ($commitNum -gt (GetCommitNumber $previewZip)){
81+
$previewZip = $pkg.Name
82+
}
83+
}
84+
elseif ($pkg.Name.EndsWith("tar.gz")){
85+
if ($commitNum -gt (GetCommitNumber $tarGz)){
86+
$tarGz = $pkg.Name
87+
}
88+
}
89+
}
90+
91+
# Changelog
92+
$changelog = Invoke-WebRequest -Uri https://raw.githubusercontent.com/Azure/azure-powershell/internal/release/ChangeLog.md
93+
$changelog = [regex]::split($changelog, "##\s\d+\.\d+\.\d+\s-\s\w+\s\d{4}")[1] -replace '^\s*\n|\n\s*$', ''
94+
95+
## TODO: add thanks list
96+
97+
# Get bumped version and previous version
98+
# Calculate 1st GA modules and preview modules
99+
$BumpedAzPreviewOutFile = "AzPreview_bumped.psd1"
100+
$PreviousAzPreviewOutFile = "AzPreview_previous.psd1"
101+
Invoke-WebRequest -Uri https://raw.githubusercontent.com/Azure/azure-powershell/internal/release/tools/AzPreview/AzPreview.psd1 -OutFile AzPreview_bumped.psd1
102+
$BumpedModuleInfos = Import-PowerShellDataFile -Path $BumpedAzPreviewOutFile
103+
Invoke-WebRequest -Uri https://raw.githubusercontent.com/Azure/azure-powershell/main/tools/AzPreview/AzPreview.psd1 -OutFile AzPreview_previous.psd1
104+
$PreviousModuleInfos = Import-PowerShellDataFile -Path $PreviousAzPreviewOutFile
105+
106+
$BumpedModuleInfos = $BumpedModuleInfos.RequiredModules
107+
$PreviousModuleInfos = $PreviousModuleInfos.RequiredModules
108+
$1stGAModules = @()
109+
$previewModules = @()
110+
111+
foreach($m in $BumpedModuleInfos){
112+
# Write-Host $m.moduleName
113+
114+
if (($m.moduleName -in $PreviousModuleInfos.ModuleName)){
115+
$previousModule = $PreviousModuleInfos | Where-Object {$_.ModuleName -eq $m.ModuleName}
116+
$previousVersion = $previousModule.RequiredVersion
117+
# GA modules
118+
if (($previousVersion -ne $m.RequiredVersion) -and ($m.RequiredVersion -eq "1.0.0")){
119+
if(-not $1stGAModules.count -gt 0){
120+
$1stGAModules += "Modules out of preview and now generally available as part of Az: ` "
121+
}
122+
$1stGAModules += "* $($m.moduleName)"
123+
}
124+
125+
if (($previousVersion -ne $m.RequiredVersion) -and ($m.RequiredVersion.StartsWith("0."))){
126+
if(-not $previewModules.count -gt 0){
127+
$previewModules += "Modules under preview (the following modules must be installed separately): `
128+
}
129+
$previewModules += "* $($m.moduleName) $($m.RequiredVersion) ` "
130+
}
131+
132+
}
133+
else{
134+
Write-Host $m.moduleName preview2
135+
if(-not $previewModules.count -gt 0){
136+
$previewModules += "Modules under preview (the following modules must be installed separately): `
137+
}
138+
$previewModules += "* $($m.moduleName) $($m.RequiredVersion) ` "
139+
}
140+
141+
}
142+
143+
if($Phase.StartsWith("RC")){
144+
$RCNum = $Phase -replace "RC", ""
145+
}
146+
147+
$template = "Az $AzVersion - Release Candidate $RCNum Now Available ` `
148+
Hi everyone, `
149+
`
150+
**The release candidate $RCNum for Az $AzVersion** is now available for testing: `
151+
`
152+
* [$x64Msi](https://azpspackage.blob.core.windows.net/release/$x64Msi) `
153+
* [$x86Msi](https://azpspackage.blob.core.windows.net/release/$x86Msi) `
154+
* [$tarGz](https://azpspackage.blob.core.windows.net/release/$tarGz) `
155+
`
156+
If you want to install module by compressed package, please run ``./InstallModule.ps1 -ModuleName Az.{ModuleName}`` after decompressing the package. If you have any questions or find any issues, please little ‘r’ the azdevxps alias. Thanks! `
157+
`
158+
If no issue is reported, this release will be considered as final release candidate and published to PSGallery. `
159+
`
160+
### Release Notes
161+
$changelog
162+
$($1stGAModules | Out-String)
163+
$($previewModules | Out-String)
164+
The preview modules (whose versions are lower than 1.0.0) are available as below: `
165+
* [$previewZip](https://azpspackage.blob.core.windows.net/release/$previewZip) `
166+
`
167+
Known issues: `
168+
* {any} `
169+
`
170+
Thanks,`
171+
<Name>"
172+
173+
if(-not $1stGAModules.count -gt 0){
174+
Write-Host No 1st GA
175+
$null = $template -replace "Modules out of preview and now generally available as part of Az:", ""
176+
}
177+
if(-not $previewModules.count -gt 0){
178+
Write-Host No preview updates
179+
$null = $template.replace("Modules under preview (the following modules mut be installed separately):", "")
180+
}
181+
182+
$template | Out-File -FilePath $OutFilePath
183+
Write-Host "Email generated under $OutFilePath, please do not forget to replace your <name> and pay attention to Known issues session."
184+
# Cleanup
185+
Remove-Item $BumpedAzPreviewOutFile
186+
Remove-Item $PreviousAzPreviewOutFile
187+
}
188+
else{
189+
Write-Host "#TODO: Publish email"
190+
}

0 commit comments

Comments
 (0)