Skip to content

Commit 9d12b36

Browse files
CodeBlanchgithub-actions[bot]reyang
authored
[repo] Release process tweaks & improvements 4 (#5598)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Reiley Yang <[email protected]>
1 parent 15cea9c commit 9d12b36

File tree

8 files changed

+430
-36
lines changed

8 files changed

+430
-36
lines changed
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
name: Prepare for a release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
tag-prefix:
7+
type: choice
8+
options:
9+
- core-
10+
- coreunstable-
11+
description: 'Release tag prefix'
12+
required: true
13+
version:
14+
type: string
15+
description: 'Release version'
16+
required: true
17+
18+
pull_request:
19+
types:
20+
- closed
21+
22+
issue_comment:
23+
types:
24+
- created
25+
26+
permissions:
27+
contents: write
28+
pull-requests: write
29+
30+
jobs:
31+
prepare-release-pr:
32+
if: github.event_name == 'workflow_dispatch'
33+
34+
runs-on: windows-latest
35+
36+
steps:
37+
- name: check out code
38+
uses: actions/checkout@v4
39+
40+
- name: Create GitHub Pull Request to prepare release
41+
shell: pwsh
42+
run: |
43+
Import-Module .\build\scripts\prepare-release.psm1
44+
45+
CreatePullRequestToUpdateChangelogsAndPublicApis `
46+
-minVerTagPrefix '${{ inputs.tag-prefix }}' `
47+
-version '${{ inputs.version }}' `
48+
-targetBranch '${{ github.ref_name }}'
49+
env:
50+
GH_TOKEN: ${{ github.token }}
51+
52+
lock-pr-and-post-notice-to-create-release-tag:
53+
if: |
54+
github.event_name == 'pull_request'
55+
&& github.event.action == 'closed'
56+
&& github.event.pull_request.user.login == 'github-actions[bot]'
57+
&& github.event.pull_request.merged == true
58+
&& startsWith(github.event.pull_request.title, '[repo] Prepare release ')
59+
60+
runs-on: windows-latest
61+
62+
steps:
63+
- name: check out code
64+
uses: actions/checkout@v4
65+
66+
- name: Lock GitHub Pull Request to prepare release
67+
shell: pwsh
68+
run: |
69+
Import-Module .\build\scripts\prepare-release.psm1
70+
71+
LockPullRequestAndPostNoticeToCreateReleaseTag `
72+
-pullRequestNumber '${{ github.event.pull_request.number }}'
73+
env:
74+
GH_TOKEN: ${{ github.token }}
75+
76+
create-release-tag-unlock-pr-post-notice:
77+
if: |
78+
github.event_name == 'issue_comment'
79+
&& github.event.issue.pull_request
80+
&& github.event.issue.locked == true
81+
&& contains(github.event.comment.body, '/CreateReleaseTag')
82+
&& startsWith(github.event.issue.title, '[repo] Prepare release ')
83+
&& github.event.issue.pull_request.merged_at
84+
85+
runs-on: windows-latest
86+
87+
outputs:
88+
tag: ${{ steps.create-tag.outputs.tag }}
89+
90+
steps:
91+
- name: check out code
92+
uses: actions/checkout@v4
93+
with:
94+
# Note: By default GitHub only fetches 1 commit which fails the git tag operation below
95+
fetch-depth: 0
96+
97+
- name: Create release tag
98+
id: create-tag
99+
shell: pwsh
100+
run: |
101+
Import-Module .\build\scripts\prepare-release.psm1
102+
103+
$tag = ''
104+
105+
CreateReleaseTag `
106+
-pullRequestNumber '${{ github.event.issue.number }}' `
107+
-actionRunId '${{ github.run_id }}' `
108+
-tag ([ref]$tag)
109+
110+
echo "tag=$tag" >> $env:GITHUB_OUTPUT
111+
env:
112+
GH_TOKEN: ${{ github.token }}
113+
114+
invoke-package-workflow:
115+
needs: create-release-tag-unlock-pr-post-notice
116+
uses: ./.github/workflows/publish-packages-1.0.yml
117+
with:
118+
tag: ${{ needs.create-release-tag-unlock-pr-post-notice.outputs.tag }}
119+
120+
post-packages-ready-notice:
121+
needs:
122+
- create-release-tag-unlock-pr-post-notice
123+
- invoke-package-workflow
124+
runs-on: windows-latest
125+
steps:
126+
- name: check out code
127+
uses: actions/checkout@v4
128+
129+
- name: Post notice when packages are ready
130+
shell: pwsh
131+
run: |
132+
Import-Module .\build\scripts\prepare-release.psm1
133+
134+
PostPackagesReadyNotice `
135+
-pullRequestNumber '${{ github.event.issue.number }}' `
136+
-tag '${{ needs.create-release-tag-unlock-pr-post-notice.outputs.tag }}' `
137+
-packagesUrl '${{ needs.invoke-package-workflow.outputs.artifact-url }}'
138+
env:
139+
GH_TOKEN: ${{ github.token }}

.github/workflows/publish-packages-1.0.yml

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@ on:
1414
- 'core-*'
1515
- 'coreunstable-*'
1616
- 'Instrumentation.*-'
17+
workflow_call:
18+
inputs:
19+
tag:
20+
required: true
21+
type: string
22+
outputs:
23+
artifact-id:
24+
value: ${{ jobs.build-pack-publish.outputs.artifact-id }}
25+
artifact-url:
26+
value: ${{ jobs.build-pack-publish.outputs.artifact-url }}
1727
schedule:
1828
- cron: '0 0 * * *' # once in a day at 00:00
1929

@@ -25,14 +35,18 @@ jobs:
2535
build-pack-publish:
2636
runs-on: windows-latest
2737

38+
outputs:
39+
artifact-id: ${{ steps.upload-artifacts.outputs.artifact-id }}
40+
artifact-url: ${{ steps.upload-artifacts.outputs.artifact-url }}
41+
2842
steps:
2943
- uses: actions/checkout@v4
3044
with:
3145
# Note: By default GitHub only fetches 1 commit. MinVer needs to find
3246
# the version tag which is typically NOT on the first commit so we
3347
# retrieve them all.
3448
fetch-depth: 0
35-
ref: ${{ github.ref || 'main' }}
49+
ref: ${{ inputs.tag || github.ref || 'main' }}
3650

3751
- name: Setup dotnet
3852
uses: actions/setup-dotnet@v4
@@ -44,12 +58,13 @@ jobs:
4458
run: dotnet build OpenTelemetry.proj --configuration Release --no-restore -p:Deterministic=true -p:BuildNumber=${{ github.run_number }} -p:RunningDotNetPack=true
4559

4660
- name: dotnet pack
47-
run: dotnet pack OpenTelemetry.proj --configuration Release --no-restore --no-build -p:PackTag=${{ github.ref_type == 'tag' && github.ref_name || '' }}
61+
run: dotnet pack OpenTelemetry.proj --configuration Release --no-restore --no-build -p:PackTag=${{ github.ref_type == 'tag' && github.ref_name || inputs.tag || '' }}
4862

4963
- name: Publish Artifacts
64+
id: upload-artifacts
5065
uses: actions/upload-artifact@v4
5166
with:
52-
name: ${{ github.ref_name }}-packages
67+
name: ${{ inputs.tag || github.ref_name }}-packages
5368
path: '**/bin/**/*.*nupkg'
5469

5570
- name: Publish MyGet
@@ -61,7 +76,7 @@ jobs:
6176
nuget push **/bin/**/*.nupkg -Source https://www.myget.org/F/opentelemetry/api/v2/package
6277
6378
- name: Create GitHub Release draft
64-
if: github.ref_type == 'tag'
79+
if: github.ref_type == 'tag' || inputs.tag
6580
shell: pwsh
6681
run: |
6782
$packages = (Get-ChildItem -Path src/*/bin/Release/*.nupkg).Name
@@ -88,7 +103,7 @@ jobs:
88103
89104
foreach ($line in $changelogContent)
90105
{
91-
if ($line -like "## ${{ github.ref_name }}" -and $started -ne $true)
106+
if ($line -like "## $packageVersion" -and $started -ne $true)
92107
{
93108
$started = $true
94109
}
@@ -122,24 +137,24 @@ jobs:
122137
123138
$content
124139
125-
See [CHANGELOG](https://github.com/${{ github.repository }}/blob/${{ github.ref_name }}/src/$packageName/CHANGELOG.md) for details.
140+
See [CHANGELOG](https://github.com/${{ github.repository }}/blob/${{ inputs.tag || github.ref_name }}/src/$packageName/CHANGELOG.md) for details.
126141
127142
"@
128143
}
129144
130145
if ($firstPackageVersion -match '-alpha' -or $firstPackageVersion -match '-beta' -or $firstPackageVersion -match '-rc')
131146
{
132-
gh release create ${{ github.ref_name }} `
133-
--title ${{ github.ref_name }} `
147+
gh release create ${{ inputs.tag || github.ref_name }} `
148+
--title ${{ inputs.tag || github.ref_name }} `
134149
--verify-tag `
135150
--notes "$notes" `
136151
--prerelease `
137152
--draft
138153
}
139154
else
140155
{
141-
gh release create ${{ github.ref_name }} `
142-
--title ${{ github.ref_name }} `
156+
gh release create ${{ inputs.tag || github.ref_name }} `
157+
--title ${{ inputs.tag || github.ref_name }} `
143158
--verify-tag `
144159
--notes "$notes" `
145160
--latest `
@@ -149,20 +164,22 @@ jobs:
149164
GH_TOKEN: ${{ github.token }}
150165

151166
- name: Create GitHub draft Pull Request to update stable build version in props
152-
if: github.ref_type == 'tag' && startsWith(github.ref_name, 'core-') && !contains(github.ref_name, '-alpha') && !contains(github.ref_name, '-beta') && !contains(github.ref_name, '-rc')
167+
if: |
168+
(github.ref_type == 'tag' && startsWith(github.ref_name, 'core-') && !contains(github.ref_name, '-alpha') && !contains(github.ref_name, '-beta') && !contains(github.ref_name, '-rc'))
169+
|| (inputs.tag && startsWith(inputs.tag, 'core-') && !contains(inputs.tag, '-alpha') && !contains(inputs.tag, '-beta') && !contains(inputs.tag, '-rc'))
153170
shell: pwsh
154171
run: |
155172
git config user.name "github-actions[bot]"
156173
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
157174
158-
git switch --create release/post-stable-${{ github.ref_name }}-update 2>&1 | % ToString
175+
git switch --create release/post-stable-${{ inputs.tag || github.ref_name }}-update main 2>&1 | % ToString
159176
if ($LASTEXITCODE -gt 0)
160177
{
161178
Write-Error 'git switch failure'
162179
Return
163180
}
164181
165-
$match = [regex]::Match('${{ github.ref_name }}', '.*?-(.*)')
182+
$match = [regex]::Match('${{ inputs.tag || github.ref_name }}', '.*?-(.*)')
166183
$packageVersion = $match.Groups[1].Value
167184
168185
(Get-Content Directory.Packages.props) `
@@ -183,7 +200,7 @@ jobs:
183200
Return
184201
}
185202
186-
git push -u origin release/post-stable-${{ github.ref_name }}-update 2>&1 | % ToString
203+
git push -u origin release/post-stable-${{ inputs.tag || github.ref_name }}-update 2>&1 | % ToString
187204
if ($LASTEXITCODE -gt 0)
188205
{
189206
Write-Error 'git push failure'
@@ -205,7 +222,7 @@ jobs:
205222
--title "[repo] Core stable release $packageVersion updates" `
206223
--body $body `
207224
--base main `
208-
--head release/post-stable-${{ github.ref_name }}-update `
225+
--head release/post-stable-${{ inputs.tag || github.ref_name }}-update `
209226
--label infra `
210227
--draft
211228
env:

.markdownlint.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
# Default state for all rules
22
default: true
33

4-
# allow long lines for tables and code blocks
4+
# MD013/line-length : Line length : https://github.com/DavidAnson/markdownlint/blob/v0.32.1/doc/md013.md
55
MD013:
66
code_blocks: false
77
tables: false
8+
9+
# MD033/no-inline-html : Inline HTML : https://github.com/DavidAnson/markdownlint/blob/v0.32.1/doc/md033.md
10+
MD033:
11+
# Allowed elements
12+
allowed_elements: [ 'details', 'summary' ]

OpenTelemetry.sln

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{7CB2F02E
3434
build\docker-compose.net6.0.yml = build\docker-compose.net6.0.yml
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
37-
build\finalize-publicapi.ps1 = build\finalize-publicapi.ps1
3837
build\GlobalAttrExclusions.txt = build\GlobalAttrExclusions.txt
3938
build\opentelemetry-icon-color.png = build\opentelemetry-icon-color.png
4039
build\OpenTelemetry.prod.loose.ruleset = build\OpenTelemetry.prod.loose.ruleset
@@ -46,7 +45,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{7CB2F02E
4645
build\test-aot-compatibility.ps1 = build\test-aot-compatibility.ps1
4746
build\test-threadSafety.ps1 = build\test-threadSafety.ps1
4847
build\UnstableCoreLibraries.proj = build\UnstableCoreLibraries.proj
49-
build\update-changelogs.ps1 = build\update-changelogs.ps1
5048
build\xunit.runner.json = build\xunit.runner.json
5149
EndProjectSection
5250
EndProject
@@ -99,6 +97,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{
9997
.github\workflows\dotnet-format.yml = .github\workflows\dotnet-format.yml
10098
.github\workflows\markdownlint.yml = .github\workflows\markdownlint.yml
10199
.github\workflows\package-validation.yml = .github\workflows\package-validation.yml
100+
.github\workflows\prepare-release.yml = .github\workflows\prepare-release.yml
102101
.github\workflows\publish-packages-1.0.yml = .github\workflows\publish-packages-1.0.yml
103102
.github\workflows\sanitycheck.yml = .github\workflows\sanitycheck.yml
104103
.github\workflows\stale.yml = .github\workflows\stale.yml
@@ -341,6 +340,9 @@ EndProject
341340
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "scripts", "scripts", "{44982E0D-C8C6-42DC-9F8F-714981F27CE6}"
342341
ProjectSection(SolutionItems) = preProject
343342
build\scripts\add-labels.ps1 = build\scripts\add-labels.ps1
343+
build\scripts\finalize-publicapi.ps1 = build\scripts\finalize-publicapi.ps1
344+
build\scripts\prepare-release.psm1 = build\scripts\prepare-release.psm1
345+
build\scripts\update-changelogs.ps1 = build\scripts\update-changelogs.ps1
344346
EndProjectSection
345347
EndProject
346348
Global

0 commit comments

Comments
 (0)