Publish NuGet (Run ID: latest build) #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish NuGet Packages | |
| run-name: "Publish NuGet (Run ID: ${{ inputs.run_id || 'latest build' }})" | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| run_id: | |
| description: "Build workflow run ID (leave empty to use latest)" | |
| required: false | |
| type: string | |
| permissions: | |
| actions: read | |
| contents: read | |
| jobs: | |
| publish: | |
| name: Publish to NuGet.org | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Get Latest Build Run ID | |
| id: get-run-id | |
| uses: ./.github/actions/get-latest-build-run-id | |
| with: | |
| run_id: ${{ inputs.run_id }} | |
| github_token: ${{ github.token }} | |
| - name: Download ApiClient NuGet Package | |
| uses: actions/download-artifact@v7 | |
| with: | |
| name: ApiClientNuGet | |
| path: ./nuget-packages | |
| github-token: ${{ github.token }} | |
| run-id: ${{ steps.get-run-id.outputs.run_id }} | |
| - name: Download DataRedaction NuGet Package | |
| uses: actions/download-artifact@v7 | |
| with: | |
| name: DataRedactionNuGet | |
| path: ./nuget-packages | |
| github-token: ${{ github.token }} | |
| run-id: ${{ steps.get-run-id.outputs.run_id }} | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: "10.x" | |
| - name: Publish to NuGet.org | |
| shell: bash | |
| run: | | |
| for package in ./nuget-packages/*.nupkg; do | |
| echo "Publishing $package..." | |
| dotnet nuget push "$package" \ | |
| --api-key ${{ secrets.NUGET_KEY }} \ | |
| --source https://api.nuget.org/v3/index.json \ | |
| --skip-duplicate | |
| done | |
| - name: Publish Complete | |
| shell: pwsh | |
| run: | | |
| Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value "## NuGet Publish Summary" | |
| Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value "**Files Published:**" | |
| foreach ($Item in Get-ChildItem -Path ./nuget-packages/*.nupkg) { | |
| Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value " - $($Item.Name)" | |
| } | |
| Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value "**Packages Published:**" | |
| Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value "- ControlR.ApiClient" | |
| Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value "- ControlR.Libraries.DataRedaction" | |
| Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value "" | |
| Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value "✅ Successfully published to NuGet.org" |