diff --git a/.github/workflows/post-release.yml b/.github/workflows/post-release.yml index 162e17f10a5..6f26e1058a3 100644 --- a/.github/workflows/post-release.yml +++ b/.github/workflows/post-release.yml @@ -21,13 +21,7 @@ jobs: needs: - automation - if: | - needs.automation.outputs.enabled - && - ( - (github.ref_type == 'tag' && startsWith(github.ref_name, 'core-') && !contains(github.ref_name, '-alpha') && !contains(github.ref_name, '-beta') && !contains(github.ref_name, '-rc')) - || (inputs.tag && startsWith(inputs.tag, 'core-') && !contains(inputs.tag, '-alpha') && !contains(inputs.tag, '-beta') && !contains(inputs.tag, '-rc')) - ) + if: needs.automation.outputs.enabled env: GH_TOKEN: ${{ secrets[needs.automation.outputs.token-secret-name] }} @@ -35,10 +29,16 @@ jobs: steps: - uses: actions/checkout@v4 with: + # Note: By default GitHub only fetches 1 commit. We need all the tags + # for this work. + fetch-depth: 0 ref: ${{ github.event.repository.default_branch }} token: ${{ secrets[needs.automation.outputs.token-secret-name] }} - name: Create GitHub Pull Request to update stable build version in props + 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')) + || (inputs.tag && startsWith(inputs.tag, 'core-') && !contains(inputs.tag, '-alpha') && !contains(inputs.tag, '-beta') && !contains(inputs.tag, '-rc')) shell: pwsh run: | Import-Module .\build\scripts\post-release.psm1 @@ -49,3 +49,23 @@ jobs: -targetBranch '${{ github.event.repository.default_branch }}' ` -gitUserName '${{ needs.automation.outputs.username }}' ` -gitUserEmail '${{ needs.automation.outputs.email }}' + + - name: Invoke core version update workflow in opentelemetry-dotnet-contrib repository + if: vars.CONTRIB_REPO + shell: pwsh + run: | + Import-Module .\build\scripts\post-release.psm1 + + InvokeCoreVersionUpdateWorkflowInRemoteRepository ` + -remoteGitRepository '${{ vars.CONTRIB_REPO }}' ` + -tag '${{ inputs.tag || github.ref_name }}' + + - name: Post notice when release is published + shell: pwsh + run: | + Import-Module .\build\scripts\post-release.psm1 + + TryPostReleasePublishedNoticeOnPrepareReleasePullRequest ` + -gitRepository '${{ github.repository }}' ` + -botUserName '${{ needs.automation.outputs.username }}' ` + -tag '${{ inputs.tag || github.ref_name }}' diff --git a/build/RELEASING.md b/build/RELEASING.md index 035aad38d6b..d25f13b1355 100644 --- a/build/RELEASING.md +++ b/build/RELEASING.md @@ -164,18 +164,21 @@ workflow creates a draft release for the tag which was pushed. Edit the draft Release and click `Publish release`. -14. If a new stable version of the core packages was released, a draft PR should - have been automatically created by the [Build, pack, and publish to - MyGet](https://github.com/open-telemetry/opentelemetry-dotnet/actions/workflows/publish-packages-1.0.yml) +14. If a new stable version of the core packages was released, a PR should have + been automatically created by the [Complete + release](https://github.com/open-telemetry/opentelemetry-dotnet/actions/workflows/post-release.yml) workflow to update the `OTelLatestStableVer` property in - `Directory.Packages.props` to the just released stable version. Mark that PR - `Ready for review` and then merge it once the build passes (this requires - the packages be available on NuGet). - -15. If a new stable version of the core packages was released, open an issue in - the - [opentelemetry-dotnet-contrib](https://github.com/open-telemetry/opentelemetry-dotnet-contrib) - repo to notify maintainers to begin upgrading dependencies. + `Directory.Packages.props` to the just released stable version. Merge that + PR once the build passes (this requires the packages be available on NuGet). + +15. The [Complete + release](https://github.com/open-telemetry/opentelemetry-dotnet/actions/workflows/post-release.yml) + workflow should have invoked the [Core version + update](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/actions/workflows/core-version-update.yml) + workflow on the + [opentelemetry-dotnet-contrib](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/) + repository which opens a PR to update dependencies. Verify this PR was + opened successfully. 16. Post an announcement in the [Slack channel](https://cloud-native.slack.com/archives/C01N3BC2W7Q). Note any big diff --git a/build/scripts/post-release.psm1 b/build/scripts/post-release.psm1 index 369d4366fb3..ca6ea1cc158 100644 --- a/build/scripts/post-release.psm1 +++ b/build/scripts/post-release.psm1 @@ -136,8 +136,6 @@ function TryPostPackagesReadyNoticeOnPrepareReleasePullRequest { $body = @" The packages for [$tag](https://github.com/$gitRepository/releases/tag/$tag) are now available: $packagesUrl. - -Have a nice day! "@ $pullRequestNumber = $pr.number @@ -227,3 +225,85 @@ Merge once packages are available on NuGet and the build passes. } Export-ModuleMember -Function CreateStableVersionUpdatePullRequest + +function InvokeCoreVersionUpdateWorkflowInRemoteRepository { + param( + [Parameter(Mandatory=$true)][string]$remoteGitRepository, + [Parameter(Mandatory=$true)][string]$tag, + [Parameter()][string]$targetBranch="main" + ) + + $match = [regex]::Match($tag, '^(.*?-)(.*)$') + if ($match.Success -eq $false) + { + throw 'Could not parse prefix or version from tag' + } + + gh workflow run "core-version-update.yml" ` + --repo $remoteGitRepository ` + --ref $targetBranch ` + --field "tag=$tag" +} + +Export-ModuleMember -Function InvokeCoreVersionUpdateWorkflowInRemoteRepository + +function TryPostReleasePublishedNoticeOnPrepareReleasePullRequest { + param( + [Parameter(Mandatory=$true)][string]$gitRepository, + [Parameter(Mandatory=$true)][string]$botUserName, + [Parameter(Mandatory=$true)][string]$tag + ) + + $tagSha = git rev-list -n 1 $tag 2>&1 | % ToString + if ($LASTEXITCODE -gt 0) + { + throw 'git rev-list failure' + } + + $prListResponse = gh pr list --search $tagSha --state merged --json number,author,title,comments | ConvertFrom-Json + + if ($prListResponse.Length -eq 0) + { + Write-Host 'No prepare release PR found for tag & commit skipping post notice' + return + } + + foreach ($pr in $prListResponse) + { + if ($pr.author.login -ne $botUserName -or $pr.title -ne "[repo] Prepare release $tag") + { + continue + } + + $foundComment = $false + foreach ($comment in $pr.comments) + { + if ($comment.author.login -eq $botUserName -and $comment.body.StartsWith("The packages for [$tag](https://github.com/$gitRepository/releases/tag/$tag) are now available:")) + { + $foundComment = $true + break + } + } + + if ($foundComment -eq $false) + { + continue + } + + $body = +@" +The release [$tag](https://github.com/$gitRepository/releases/tag/$tag) has been published and packages should be available on NuGet momentarily. + +Have a nice day! +"@ + + $pullRequestNumber = $pr.number + + gh pr comment $pullRequestNumber --body $body + return + } + + Write-Host 'No prepare release PR found matched author and title with a valid comment' +} + +Export-ModuleMember -Function TryPostReleasePublishedNoticeOnPrepareReleasePullRequest