Skip to content

Commit 994b890

Browse files
authored
[repo] Improve the scripts used in the release process (#5561)
1 parent efe97bf commit 994b890

5 files changed

+129
-98
lines changed

OpenTelemetry.sln

+3-6
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,20 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{7CB2F02E
3535
build\docker-compose.net7.0.yml = build\docker-compose.net7.0.yml
3636
build\docker-compose.net8.0.yml = build\docker-compose.net8.0.yml
3737
build\finalize-publicapi.ps1 = build\finalize-publicapi.ps1
38+
build\generate-combined-changelog.ps1 = build\generate-combined-changelog.ps1
3839
build\GlobalAttrExclusions.txt = build\GlobalAttrExclusions.txt
3940
build\InstrumentationLibraries.proj = build\InstrumentationLibraries.proj
4041
build\opentelemetry-icon-color.png = build\opentelemetry-icon-color.png
4142
build\OpenTelemetry.prod.loose.ruleset = build\OpenTelemetry.prod.loose.ruleset
4243
build\OpenTelemetry.prod.ruleset = build\OpenTelemetry.prod.ruleset
4344
build\OpenTelemetry.test.ruleset = build\OpenTelemetry.test.ruleset
44-
build\process-codecoverage.ps1 = build\process-codecoverage.ps1
4545
build\RELEASING.md = build\RELEASING.md
4646
build\stylecop.json = build\stylecop.json
4747
build\test-aot-compatibility.ps1 = build\test-aot-compatibility.ps1
4848
build\test-threadSafety.ps1 = build\test-threadSafety.ps1
49-
build\xunit.runner.json = build\xunit.runner.json
5049
build\UnstableCoreLibraries.proj = build\UnstableCoreLibraries.proj
50+
build\update-changelogs.ps1 = build\update-changelogs.ps1
51+
build\xunit.runner.json = build\xunit.runner.json
5152
EndProjectSection
5253
EndProject
5354
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Exporter.Zipkin", "src\OpenTelemetry.Exporter.Zipkin\OpenTelemetry.Exporter.Zipkin.csproj", "{7EDAE7FA-B44E-42CA-80FA-7DF2FAA2C5DD}"
@@ -531,10 +532,6 @@ Global
531532
{41B784AA-3301-4126-AF9F-1D59BD04B0BF}.Debug|Any CPU.Build.0 = Debug|Any CPU
532533
{41B784AA-3301-4126-AF9F-1D59BD04B0BF}.Release|Any CPU.ActiveCfg = Release|Any CPU
533534
{41B784AA-3301-4126-AF9F-1D59BD04B0BF}.Release|Any CPU.Build.0 = Release|Any CPU
534-
{D4519DF6-CC72-4AC4-A851-E21383098D11}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
535-
{D4519DF6-CC72-4AC4-A851-E21383098D11}.Debug|Any CPU.Build.0 = Debug|Any CPU
536-
{D4519DF6-CC72-4AC4-A851-E21383098D11}.Release|Any CPU.ActiveCfg = Release|Any CPU
537-
{D4519DF6-CC72-4AC4-A851-E21383098D11}.Release|Any CPU.Build.0 = Release|Any CPU
538535
{6C7A1595-36D6-4229-BBB5-5A6B5791791D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
539536
{6C7A1595-36D6-4229-BBB5-5A6B5791791D}.Debug|Any CPU.Build.0 = Debug|Any CPU
540537
{6C7A1595-36D6-4229-BBB5-5A6B5791791D}.Release|Any CPU.ActiveCfg = Release|Any CPU

build/RELEASING.md

+33-69
Original file line numberDiff line numberDiff line change
@@ -57,68 +57,32 @@
5757
`OTelLatestStableVer` property in `Directory.Packages.props` has been
5858
updated to the latest stable core version.
5959

60-
2. Run the following PowerShell from the root of the repo to get combined
61-
changelog (to be used later).
60+
2. Generate combined CHANGELOG
6261

63-
```powershell
64-
$changelogs = Get-ChildItem -Path . -Recurse -Filter changelog.md
65-
foreach ($changelog in $changelogs)
66-
{
67-
Add-Content -Path .\combinedchangelog.md -Value "**$($changelog.Directory.Name)**"
68-
$lines = Get-Content -Path $changelog.FullName
69-
$started = $false
70-
$ended = $false
71-
foreach ($line in $lines)
72-
{
73-
if($line -like "## Unreleased" -and $started -ne $true)
74-
{
75-
$started = $true
76-
}
77-
elseif($line -like "## *" -and $started -eq $true)
78-
{
79-
$ended = $true
80-
break
81-
}
82-
else
83-
{
84-
if ($started -eq $true)
85-
{
86-
Add-Content -Path .\combinedchangelog.md $line
87-
}
88-
}
89-
}
90-
}
91-
```
62+
Run the PowerShell script `.\build\generate-combined-changelog.ps1
63+
-minVerTagPrefix [MinVerTagPrefix]`. Where `[MinVerTagPrefix]` is the tag
64+
prefix (eg `core-`) for the components being released. This generates a
65+
combined changelog file to be used in GitHub release. The file is created in
66+
the repo root but should not be checked in. Move it or copy the contents off
67+
and then delete the file.
9268

93-
This generates combined changelog to be used in GitHub release. Once
94-
contents of combined changelog is saved somewhere, delete the file.
69+
3. Update CHANGELOG files
9570

96-
3. Run the following PowerShell script from the root of the repo. This updates
97-
all the changelog to have release date for the current version being
98-
released. Replace the version with actual version. In the script below,
99-
replace `1.4.0-beta.1` with the tag name chosen for the package in Step 1.
100-
101-
```powershell
102-
$changelogs = Get-ChildItem -Path . -Recurse -Filter changelog.md
103-
foreach ($changelog in $changelogs)
104-
{
105-
(Get-Content -Path $changelog.FullName) -replace "Unreleased", "Unreleased
106-
107-
## 1.4.0-beta.1
108-
109-
Released $(Get-Date -UFormat '%Y-%b-%d')" | Set-Content -Path $changelog.FullName
110-
}
111-
```
71+
Run the PowerShell script `.\build\update-changelogs.ps1 -minVerTagPrefix
72+
[MinVerTagPrefix] -version [Version]`. Where `[MinVerTagPrefix]` is the tag
73+
prefix (eg `core-`) for the components being released and `[Version]` is the
74+
version being released (eg `1.9.0`). This will update `CHANGELOG.md` files
75+
for the projects being released.
11276

113-
4. Normalize PublicApi files (Stable Release Only): Run the PowerShell script
114-
`.\build\finalize-publicapi.ps1`. This will merge the contents of
115-
Unshipped.txt into the Shipped.txt.
77+
4. **Stable releases only**: Normalize PublicApi files
11678

117-
5. The scripts in steps 2-4 run over the entire repo. Remove and undo changes
118-
under projects which are not being released. Submit a PR with the final
119-
changes and get it merged.
79+
Run the PowerShell script `.\build\finalize-publicapi.ps1 -minVerTagPrefix
80+
[MinVerTagPrefix]`. Where `[MinVerTagPrefix]` is the tag prefix (eg `core-`)
81+
for the components being released. This will merge the contents of any
82+
detected `PublicAPI.Unshipped.txt` files in the `.publicApi` folder into the
83+
corresponding `PublicAPI.Shipped.txt` files for the projects being released.
12084

121-
6. Tag Git with version to be released. We use
85+
5. Tag Git with version to be released. We use
12286
[MinVer](https://github.com/adamralph/minver) to do versioning, which
12387
produces version numbers based on git tags.
12488

@@ -151,7 +115,7 @@
151115
git push origin Instrumentation.AspNetCore-1.6.0
152116
```
153117

154-
7. Go to the [list of
118+
6. Go to the [list of
155119
tags](https://github.com/open-telemetry/opentelemetry-dotnet/tags) and find
156120
the tag(s) which were pushed. Click the three dots next to the tag and
157121
choose `Create release`.
@@ -164,47 +128,47 @@
164128
MyGet
165129
workflow](https://github.com/open-telemetry/opentelemetry-dotnet/actions/workflows/publish-packages-1.0.yml).
166130

167-
8. Validate using MyGet packages. Basic sanity checks :)
131+
7. Validate using MyGet packages. Basic sanity checks :)
168132

169-
9. From the above build, get the artifacts from the drop, which has all the
133+
8. From the above build, get the artifacts from the drop, which has all the
170134
NuGet packages.
171135

172-
10. Copy all the NuGet files and symbols for the packages being released into a
136+
9. Copy all the NuGet files and symbols for the packages being released into a
173137
local folder.
174138

175-
11. Download latest [nuget.exe](https://www.nuget.org/downloads) into the same
176-
folder from Step 10.
139+
10. Download latest [nuget.exe](https://www.nuget.org/downloads) into the same
140+
folder from Step 9.
177141

178-
12. Create or regenerate an API key from nuget.org (only maintainers have
142+
11. Create or regenerate an API key from nuget.org (only maintainers have
179143
access). When creating API keys make sure it is set to expire in 1 day or
180144
less.
181145

182-
13. Run the following commands from PowerShell from local folder used in Step 10:
146+
12. Run the following commands from PowerShell from local folder used in Step 9:
183147

184148
```powershell
185149
.\nuget.exe setApiKey <actual api key>
186150
187151
get-childitem -Recurse | where {$_.extension -eq ".nupkg"} | foreach ($_) {.\nuget.exe push $_.fullname -Source https://api.nuget.org/v3/index.json}
188152
```
189153
190-
14. Validate that the package(s) are uploaded. Packages are available
154+
13. Validate that the package(s) are uploaded. Packages are available
191155
immediately to maintainers on nuget.org but aren't publicly visible until
192156
scanning completes. This process usually takes a few minutes.
193157
194-
15. If a new stable version of the core packages was released, open a PR to
158+
14. If a new stable version of the core packages was released, open a PR to
195159
update the `OTelLatestStableVer` property in `Directory.Packages.props` to
196160
the just released stable version.
197161
198-
16. If a new stable version of a package with a dedicated `MinVerTagPrefix` was
162+
15. If a new stable version of a package with a dedicated `MinVerTagPrefix` was
199163
released (typically instrumentation packages) open a PR to update
200164
`PackageValidationBaselineVersion` in the project file to reflect the stable
201165
version which was just released.
202166
203-
17. If a new stable version of the core packages was released, open an issue in
167+
16. If a new stable version of the core packages was released, open an issue in
204168
the
205169
[opentelemetry-dotnet-contrib](https://github.com/open-telemetry/opentelemetry-dotnet-contrib)
206170
repo to notify maintainers to begin upgrading dependencies.
207171
208-
18. Once the packages are available on nuget.org post an announcement in the
172+
17. Once the packages are available on nuget.org post an announcement in the
209173
[Slack channel](https://cloud-native.slack.com/archives/C01N3BC2W7Q). Note
210174
any big or interesting new features as part of the announcement.

build/finalize-publicapi.ps1

+31-23
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,39 @@
1-
# After every stable release, all PublicApi text files (Shipped & Unshipped) should be merged.
2-
$path = "src\*\.publicApi\**\";
3-
$directory = Split-Path -Path $PSScriptRoot -Parent;
1+
param(
2+
[Parameter(Mandatory=$true)][string]$minVerTagPrefix
3+
)
44

5-
$searchPath = Join-Path -Path $directory -ChildPath $path;
6-
Write-Host "Search Directory: $searchPath";
7-
Write-Host "";
5+
# For stable releases "Unshipped" PublicApi text files are merged into "Shipped" versions.
86

9-
Get-ChildItem -Path $searchPath -Recurse -Filter *.Shipped.txt |
10-
ForEach-Object {
11-
Write-Host $_.FullName;
7+
$projectDirs = Get-ChildItem -Path src/**/*.csproj | Select-String "<MinVerTagPrefix>$minVerTagPrefix</MinVerTagPrefix>" -List | Select Path | Split-Path -Parent
128

13-
[string]$shipped = $_.FullName;
14-
[string]$unshipped = $shipped -replace ".shipped.txt", ".Unshipped.txt";
9+
$path = "\.publicApi\**\PublicAPI.Shipped.txt";
1510

16-
if (Test-Path $unshipped) {
17-
Write-Host $unshipped;
11+
foreach ($projectDir in $projectDirs) {
12+
$searchPath = Join-Path -Path $projectDir -ChildPath $path;
1813

19-
Get-Content $shipped, $unshipped | # get contents of both text files
20-
Where-Object {$_ -ne ""} | # filter empty lines
21-
Sort-Object | # sort lines
22-
Get-Unique | # filter duplicates
23-
Set-Content $shipped; # write to shipped.txt
14+
Write-Host "Search glob: $searchPath";
2415

25-
Clear-Content $unshipped; # empty unshipped.txt
16+
Get-ChildItem -Path $searchPath -Recurse |
17+
ForEach-Object {
18+
Write-Host "Shipped: $_";
2619

27-
Write-Host "...MERGED and SORTED";
28-
}
20+
[string]$shipped = $_.FullName;
21+
[string]$unshipped = $shipped -replace ".shipped.txt", ".Unshipped.txt";
22+
23+
if (Test-Path $unshipped) {
24+
Write-Host "Unshipped: $unshipped";
25+
26+
Get-Content $shipped, $unshipped | # get contents of both text files
27+
Where-Object {$_ -ne ""} | # filter empty lines
28+
Sort-Object | # sort lines
29+
Get-Unique | # filter duplicates
30+
Set-Content $shipped; # write to shipped.txt
2931

30-
Write-Host "";
31-
}
32+
Clear-Content $unshipped; # empty unshipped.txt
33+
34+
Write-Host "...MERGED and SORTED";
35+
}
36+
37+
Write-Host "";
38+
}
39+
}

build/generate-combined-changelog.ps1

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
param(
2+
[Parameter(Mandatory=$true)][string]$minVerTagPrefix
3+
)
4+
5+
$projectDirs = Get-ChildItem -Path src/**/*.csproj | Select-String "<MinVerTagPrefix>$minVerTagPrefix</MinVerTagPrefix>" -List | Select Path | Split-Path -Parent
6+
7+
foreach ($projectDir in $projectDirs) {
8+
$path = Join-Path -Path $projectDir -ChildPath "CHANGELOG.md"
9+
10+
$directory = Split-Path $Path -Parent | Split-Path -Leaf
11+
12+
$lines = Get-Content -Path $path
13+
14+
$headingWritten = $false
15+
$started = $false
16+
$content = ""
17+
18+
foreach ($line in $lines)
19+
{
20+
if ($line -like "## Unreleased" -and $started -ne $true)
21+
{
22+
$started = $true
23+
}
24+
elseif ($line -like "## *" -and $started -eq $true)
25+
{
26+
break
27+
}
28+
else
29+
{
30+
if ($started -eq $true)
31+
{
32+
$content += $line + "`r`n"
33+
}
34+
}
35+
}
36+
37+
if ([string]::IsNullOrWhitespace($content) -eq $false)
38+
{
39+
Add-Content -Path ".\$($minVerTagPrefix)combinedchangelog.md" -Value "**$($directory)**"
40+
Add-Content -Path ".\$($minVerTagPrefix)combinedchangelog.md" -NoNewline -Value $content
41+
}
42+
}

build/update-changelogs.ps1

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
param(
2+
[Parameter(Mandatory=$true)][string]$minVerTagPrefix,
3+
[Parameter(Mandatory=$true)][string]$version
4+
)
5+
6+
$projectDirs = Get-ChildItem -Path src/**/*.csproj | Select-String "<MinVerTagPrefix>$minVerTagPrefix</MinVerTagPrefix>" -List | Select Path | Split-Path -Parent
7+
8+
$content = "Unreleased
9+
10+
## $version
11+
12+
Released $(Get-Date -UFormat '%Y-%b-%d')"
13+
14+
foreach ($projectDir in $projectDirs) {
15+
$path = Join-Path -Path $projectDir -ChildPath "CHANGELOG.md"
16+
17+
Write-Host "Updating $path"
18+
19+
(Get-Content -Path $path) -replace "Unreleased", $content | Set-Content -Path $path
20+
}

0 commit comments

Comments
 (0)