1313 tags :
1414 - ' core-*'
1515 - ' coreunstable-*'
16- - ' Instrumentation.*-'
1716 workflow_call :
1817 inputs :
1918 tag :
@@ -79,87 +78,10 @@ jobs:
7978 if : github.ref_type == 'tag' || inputs.tag
8079 shell : pwsh
8180 run : |
82- $packages = (Get-ChildItem -Path src/*/bin/Release/*.nupkg).Name
83-
84- $notes = ''
85- $firstPackageVersion = ''
86-
87- foreach ($package in $packages)
88- {
89- $match = [regex]::Match($package, '(.*)\.(\d+\.\d+\.\d+.*?)\.nupkg')
90- $packageName = $match.Groups[1].Value
91- $packageVersion = $match.Groups[2].Value
92-
93- if ($firstPackageVersion -eq '')
94- {
95- $firstPackageVersion = $packageVersion
96- }
97-
98- $changelogContent = Get-Content -Path "src/$packageName/CHANGELOG.md"
99-
100- $headingWritten = $false
101- $started = $false
102- $content = ""
103-
104- foreach ($line in $changelogContent)
105- {
106- if ($line -like "## $packageVersion" -and $started -ne $true)
107- {
108- $started = $true
109- }
110- elseif ($line -like "Released *" -and $started -eq $true)
111- {
112- continue
113- }
114- elseif ($line -like "## *" -and $started -eq $true)
115- {
116- break
117- }
118- else
119- {
120- if ($started -eq $true -and ([string]::IsNullOrWhitespace($line) -eq $false -or $content.Length -gt 0))
121- {
122- $content += " " + $line + "`r`n"
123- }
124- }
125- }
126-
127- if ([string]::IsNullOrWhitespace($content) -eq $true)
128- {
129- $content = " No notable changes."
130- }
131-
132- $content = $content.trimend()
133-
134- $notes +=
135- @"
136- * NuGet: [$packageName v$packageVersion](https://www.nuget.org/packages/$packageName/$packageVersion)
137-
138- $content
139-
140- See [CHANGELOG](https://github.com/${{ github.repository }}/blob/${{ inputs.tag || github.ref_name }}/src/$packageName/CHANGELOG.md) for details.
141-
142- "@
143- }
144-
145- if ($firstPackageVersion -match '-alpha' -or $firstPackageVersion -match '-beta' -or $firstPackageVersion -match '-rc')
146- {
147- gh release create ${{ inputs.tag || github.ref_name }} `
148- --title ${{ inputs.tag || github.ref_name }} `
149- --verify-tag `
150- --notes "$notes" `
151- --prerelease `
152- --draft
153- }
154- else
155- {
156- gh release create ${{ inputs.tag || github.ref_name }} `
157- --title ${{ inputs.tag || github.ref_name }} `
158- --verify-tag `
159- --notes "$notes" `
160- --latest `
161- --draft
162- }
81+ Import-Module .\build\scripts\post-release.psm1
82+
83+ CreateDraftRelease `
84+ -tag '${{ inputs.tag || github.ref_name }}'
16385 env :
16486 GH_TOKEN : ${{ github.token }}
16587
@@ -169,61 +91,9 @@ jobs:
16991 || (inputs.tag && startsWith(inputs.tag, 'core-') && !contains(inputs.tag, '-alpha') && !contains(inputs.tag, '-beta') && !contains(inputs.tag, '-rc'))
17092 shell : pwsh
17193 run : |
172- git config user.name "github-actions[bot]"
173- git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
174-
175- git switch --create release/post-stable-${{ inputs.tag || github.ref_name }}-update main 2>&1 | % ToString
176- if ($LASTEXITCODE -gt 0)
177- {
178- Write-Error 'git switch failure'
179- Return
180- }
181-
182- $match = [regex]::Match('${{ inputs.tag || github.ref_name }}', '.*?-(.*)')
183- $packageVersion = $match.Groups[1].Value
184-
185- (Get-Content Directory.Packages.props) `
186- -replace '<OTelLatestStableVer>.*<\/OTelLatestStableVer>', "<OTelLatestStableVer>$packageVersion</OTelLatestStableVer>" |
187- Set-Content Directory.Packages.props
188-
189- git add Directory.Packages.props 2>&1 | % ToString
190- if ($LASTEXITCODE -gt 0)
191- {
192- Write-Error 'git add failure'
193- Return
194- }
195-
196- git commit -m "Update OTelLatestStableVer in Directory.Packages.props to $packageVersion." 2>&1 | % ToString
197- if ($LASTEXITCODE -gt 0)
198- {
199- Write-Error 'git commit failure'
200- Return
201- }
202-
203- git push -u origin release/post-stable-${{ inputs.tag || github.ref_name }}-update 2>&1 | % ToString
204- if ($LASTEXITCODE -gt 0)
205- {
206- Write-Error 'git push failure'
207- Return
208- }
209-
210- $body =
211- @"
212- Note: This PR was opened automatically by the [package workflow](https://github.com/${{ github.repository }}/actions/workflows/publish-packages-1.0.yml).
213-
214- Merge once packages are available on NuGet and the build passes.
215-
216- ## Changes
217-
218- * Sets `OTelLatestStableVer` in `Directory.Packages.props` to `$packageVersion`.
219- "@
220-
221- gh pr create `
222- --title "[repo] Core stable release $packageVersion updates" `
223- --body $body `
224- --base main `
225- --head release/post-stable-${{ inputs.tag || github.ref_name }}-update `
226- --label infra `
227- --draft
94+ Import-Module .\build\scripts\post-release.psm1
95+
96+ CreateStableVersionUpdatePullRequest `
97+ -tag '${{ inputs.tag || github.ref_name }}'
22898 env :
22999 GH_TOKEN : ${{ github.token }}
0 commit comments