From 4d0a5ba854ef8e1b53847c7f0400f60b6dcf98b0 Mon Sep 17 00:00:00 2001 From: glopesdev Date: Tue, 3 Nov 2026 23:03:53 +0000 Subject: [PATCH] Publish to NuGet.org via trusted publishing The NuGet.org publishing job now requests an OIDC token and exchanges it for a short-lived API key, in place of the stored key. --- .github/workflows/Harp.Generators.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/Harp.Generators.yml b/.github/workflows/Harp.Generators.yml index 3a30a07..4cd4e6b 100644 --- a/.github/workflows/Harp.Generators.yml +++ b/.github/workflows/Harp.Generators.yml @@ -242,6 +242,9 @@ jobs: environment: public-release needs: build if: github.event_name == 'release' + permissions: + # Needed to request the OIDC token for NuGet.org trusted publishing + id-token: write steps: # ----------------------------------------------------------------------- Set up .NET - name: Setup .NET @@ -257,8 +260,14 @@ jobs: path: artifacts/packages/ # ----------------------------------------------------------------------- Push to NuGet.org + - name: Log in to NuGet.org with OIDC + uses: NuGet/login@v1 + id: nuget-login + with: + user: ${{secrets.NUGET_USER}} + - name: Push to NuGet.org - run: dotnet nuget push "artifacts/packages/*.nupkg" --api-key ${{secrets.NUGET_API_KEY}} --source ${{vars.NUGET_API_URL}} + run: dotnet nuget push "artifacts/packages/*.nupkg" --api-key ${{steps.nuget-login.outputs.NUGET_API_KEY}} --source ${{vars.NUGET_API_URL}} env: # This is a workaround for https://github.com/NuGet/Home/issues/9775 DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER: 0