diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index d4cc393..e97bb2b 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -672,6 +672,9 @@ jobs: needs: [pack-and-validate, verify-docs-build] if: needs.pack-and-validate.outputs.has-packages == 'true' runs-on: windows-latest + permissions: + id-token: write # required for OIDC token issuance to nuget.org + contents: read steps: - name: Setup .NET uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6 @@ -691,22 +694,19 @@ jobs: name: nuget-packages path: ./packages - - name: Validate NuGet API key - shell: pwsh - env: - NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} - run: | - if ([string]::IsNullOrEmpty($env:NUGET_API_KEY)) { - Write-Error "❌ NUGET_API_KEY secret not configured!" - Write-Host "Please add it in: Repository Settings → Secrets and variables → Actions → New repository secret" - exit 1 - } - Write-Host "✅ NUGET_API_KEY is configured" -ForegroundColor Green + - name: NuGet login (OIDC → temporary API key) + # Trusted Publishing: exchange the workflow's GitHub OIDC token for an + # ephemeral (~1h) push key. No long-lived NUGET_API_KEY secret is used. + # Requires a Trusted Publishing policy for each package on nuget.org. + uses: NuGet/login@8d196754b4036150537f80ac539e15c2f1028841 # v1 + id: nuget-login + with: + user: Chris-Wolfgang - name: Publish to NuGet shell: pwsh env: - NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} + NUGET_API_KEY: ${{ steps.nuget-login.outputs.NUGET_API_KEY }} run: | $packages = Get-ChildItem -Path './packages' -Filter '*.nupkg' -ErrorAction SilentlyContinue