Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 103 additions & 0 deletions .github/workflows/nuget-packages-published.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: NuGet Packages Published
run-name: ${{ github.event.client_payload.release_tag }}

on:
repository_dispatch:
types: [ nuget_packages_published ]

permissions: {}

jobs:

wait-for-publish:
runs-on: [ ubuntu-latest ]
timeout-minutes: 60

concurrency:
group: '${{ github.workflow }}-${{ github.event.client_payload.release_tag }}'
cancel-in-progress: false

env:
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_GENERATE_ASPNET_CERTIFICATE: false
DOTNET_MULTILEVEL_LOOKUP: 0
DOTNET_NOLOGO: true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: 1
FORCE_COLOR: 3
NUGET_XMLDOC_MODE: skip
TERM: xterm

outputs:
published: ${{ steps.wait-for-publish.outputs.published }}

permissions:
contents: read

steps:

- name: Setup .NET SDK
uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0
with:
dotnet-version: ${{ github.event.client_payload.dotnet_sdk_version }}

- name: Install WaitForNuGetPackage tool
shell: pwsh
env:
# renovate: datasource=nuget depName=MartinCostello.WaitForNuGetPackage
WAIT_FOR_NUGET_PACKAGE_VERSION: '1.3.0'
run: |
dotnet tool install --global MartinCostello.WaitForNuGetPackage --version ${env:WAIT_FOR_NUGET_PACKAGE_VERSION} --allow-roll-forward

- name: Download NuGet packages
shell: pwsh
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PACKAGES_DIRECTORY: ${{ github.workspace }}/packages
RELEASE_TAG: ${{ github.event.client_payload.release_tag }}
run: |
gh release download ${env:RELEASE_TAG} --pattern "*.nupkg" --dir ${env:PACKAGES_DIRECTORY}

- name: Wait for NuGet packages to be published
id: wait-for-publish
shell: pwsh
env:
PACKAGES_DIRECTORY: ${{ github.workspace }}/packages
PUBLISH_TIMEOUT: '00:45:00'
run: |
dotnet wait-for-package --directory ${env:PACKAGES_DIRECTORY} --timeout ${env:PUBLISH_TIMEOUT}

if ($LASTEXITCODE -ne 0) {
Write-Output "::warning::Failed to wait for NuGet packages to be published and indexed."
exit 0
}

"published=true" >> ${env:GITHUB_OUTPUT}

notify-release:
runs-on: [ ubuntu-latest ]
needs: [ wait-for-publish ]
if: needs.wait-for-publish.outputs.published == 'true'

concurrency:
group: '${{ github.workflow }}-notify'
cancel-in-progress: false

steps:
- name: Create GitHub token
uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1
id: otelbot-token
with:
client-id: ${{ vars.OTELBOT_DOTNET_APP_ID }}
private-key: ${{ secrets.OTELBOT_DOTNET_PRIVATE_KEY }}
permission-pull-requests: write

- name: Post comment on release PR
shell: pwsh
env:
GH_TOKEN: ${{ steps.otelbot-token.outputs.token }}
PR_NUMBER: ${{ github.event.client_payload.pull_request_number }}
RELEASE_TAG: ${{ github.event.client_payload.release_tag }}
RELEASE_URL: ${{ format('{0}/releases/tag/{1}', github.repositoryUrl, github.event.client_payload.release_tag) }}
run: |
gh pr comment ${env:PR_NUMBER} --body "The packages for the [${env:RELEASE_TAG}](${env:RELEASE_URL}) release are now available from NuGet.org :package:"
19 changes: 18 additions & 1 deletion .github/workflows/post-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ jobs:

- name: Setup dotnet
uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0
id: setup-dotnet

- name: Create GitHub Pull Request to update stable build version in props
if: |
Expand All @@ -141,6 +142,7 @@ jobs:
-gitUserEmail ${env:BOT_USER_EMAIL}

- name: Post notice when release is published
id: post-notice
shell: pwsh
env:
GH_TOKEN: ${{ steps.otelbot-token.outputs.token }}
Expand All @@ -150,8 +152,23 @@ jobs:
run: |
Import-Module .\build\scripts\post-release.psm1

TryPostReleasePublishedNoticeOnPrepareReleasePullRequest `
$prNumber = TryPostReleasePublishedNoticeOnPrepareReleasePullRequest `
-gitRepository ${env:GITHUB_REPOSITORY} `
-expectedPrAuthorUserName ${env:EXPECTED_PR_AUTHOR_USER_NAME} `
-expectedCommentAuthorUserName ${env:EXPECTED_COMMENT_AUTHOR_USER_NAME} `
-tag ${env:TAG}

"pr-number=${prNumber}" >> ${env:GITHUB_OUTPUT}

- name: Publish nuget_packages_published
if: steps.post-notice.outputs.pr-number != ''
uses: peter-evans/repository-dispatch@28959ce8df70de7be546dd1250a005dd32156697 # v4.0.1
with:
event-type: nuget_packages_published
token: ${{ steps.otelbot-token.outputs.token }}
client-payload: |-
{
"dotnet_sdk_version": "${{ steps.setup-dotnet.outputs.dotnet-version }}",
"pull_request_number": "${{ steps.post-notice.outputs.pr-number }}",
"release_tag": "${{ inputs.tag || github.ref_name }}"
}
4 changes: 2 additions & 2 deletions build/scripts/post-release.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ function TryPostReleasePublishedNoticeOnPrepareReleasePullRequest {
if ($prListResponse.Length -eq 0)
{
Write-Host 'No prepare release PR found for tag & commit skipping post notice'
return
return $null
}

foreach ($pr in $prListResponse)
Expand Down Expand Up @@ -602,7 +602,7 @@ Have a nice day!
$pullRequestNumber = $pr.number

gh pr comment $pullRequestNumber --body $body
return
return $pullRequestNumber
}

Write-Host 'No prepare release PR found matched author and title with a valid comment'
Expand Down