From 3d748f24f99cafe9178bfda380c66db7071fd1e8 Mon Sep 17 00:00:00 2001 From: Marcus Carey Date: Fri, 6 Nov 2026 15:15:13 -0600 Subject: [PATCH] chore: publish to nuget.org with trusted publishing Swap the long-lived NuGet API key secret for nuget.org trusted publishing: the release job gets an OIDC token (id-token: write), NuGet/login exchanges it for a one-hour API key, and dotnet nuget push uses that key. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01YUXrZTZXQWDbUQnK4Fx47r --- .github/workflows/dotnet-release.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/dotnet-release.yml b/.github/workflows/dotnet-release.yml index 3260af3..44c3917 100644 --- a/.github/workflows/dotnet-release.yml +++ b/.github/workflows/dotnet-release.yml @@ -9,6 +9,9 @@ jobs: build: runs-on: ubuntu-latest + permissions: + contents: read + id-token: write # nuget.org trusted publishing (OIDC) steps: - name: Setup Git @@ -57,9 +60,16 @@ jobs: if: steps.versionize.outcome == 'success' run : dotnet pack **/*/JsonPatchGenerator.csproj --configuration Release -o out/pack + - name: NuGet login (trusted publishing) + id: nuget-login + if: steps.versionize.outcome == 'success' + uses: NuGet/login@v1 + with: + user: ${{ vars.NUGET_USER }} + - name: Publish if: steps.versionize.outcome == 'success' - run: dotnet nuget push ./out/pack/*.nupkg --api-key ${{secrets.FIREBEND_NUGET_KEY}} --skip-duplicate --source https://api.nuget.org/v3/index.json + run: dotnet nuget push ./out/pack/*.nupkg --api-key ${{ steps.nuget-login.outputs.NUGET_API_KEY }} --skip-duplicate --source https://api.nuget.org/v3/index.json - name: Push version changes if: steps.versionize.outcome == 'success'