From 6049e687fd9a0aeddaee13963f5e3b5aa0f0a83f Mon Sep 17 00:00:00 2001 From: Pieter van Ginkel Date: Sat, 21 Nov 2026 20:09:50 +0100 Subject: [PATCH] Publish to NuGet.org through trusted publishing. nuget.org now caps API keys at 30 days and steers GitHub Actions to trusted publishing. The release workflow trades its OIDC token for a one-hour key through NuGet/login, which needs id-token: write and the nuget.org username in the NUGET_USER secret, and the trusted publishing policy on nuget.org for TQLApp/TQL and release.yml. NUGET_API_KEY is no longer used. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01RGjkV4gS8yYKqvzQa4b3Tg --- .github/workflows/release.yml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2cacfe2..526c76d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,6 +8,9 @@ on: permissions: contents: write packages: write + # NuGet trusted publishing: NuGet/login trades the workflow's OIDC token for a + # one-hour nuget.org API key. + id-token: write jobs: release: @@ -52,11 +55,19 @@ jobs: - name: Build Solution run: dotnet build -c Release -property:Version="${{ steps.get-build-version.outputs.build-version }}" -warnaserror + # The key lasts an hour, so this runs right before the pushes. It needs the + # trusted publishing policy on nuget.org for TQLApp/TQL and release.yml. + - name: Log in to NuGet.org + uses: NuGet/login@v1 + id: nuget-login + with: + user: ${{ secrets.NUGET_USER }} + - name: Publish NuGet packages to NuGet.org - run: dotnet nuget push "**/*.nupkg" --api-key "${{ secrets.NUGET_API_KEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate + run: dotnet nuget push "**/*.nupkg" --api-key "${{ steps.nuget-login.outputs.NUGET_API_KEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate - name: Publish symbol NuGet packages to NuGet.org - run: dotnet nuget push "**/*.snupkg" --api-key "${{ secrets.NUGET_API_KEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate + run: dotnet nuget push "**/*.snupkg" --api-key "${{ steps.nuget-login.outputs.NUGET_API_KEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate - name: Publish App run: dotnet publish -c Release -r win-x64 --self-contained src\Tql.App -property:Version="${{ steps.get-build-version.outputs.build-version }}" -warnaserror