From 33f6979949a27468e4a3f31c38fe5c3ec6ce1361 Mon Sep 17 00:00:00 2001 From: stesee <168659+stesee@users.noreply.github.com> Date: Sun, 1 Nov 2026 22:04:27 +0000 Subject: [PATCH] Use NuGet Trusted Publishing for release push instead of API key --- .github/workflows/dotnet.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 5b0bebce..c8251e59 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -47,18 +47,23 @@ jobs: if: github.ref == 'refs/heads/release' runs-on: ubuntu-latest needs: build + permissions: + contents: write # gh release create + id-token: write # NuGet Trusted Publishing (OIDC) steps: - uses: actions/checkout@v7 - name: Download build artifacts uses: actions/download-artifact@v8 with: name: build-artifacts + - name: NuGet login (Trusted Publishing) + uses: NuGet/login@v1 + id: nugetLogin + with: + user: ${{ secrets.NUGET_USER }} - name: NugetPush - env: - NUGET_TOKEN_EXISTS: ${{ secrets.NUGET_TOKEN }} - if: env.NUGET_TOKEN_EXISTS != '' run: | - dotnet nuget push *.nupkg --skip-duplicate --api-key ${{secrets.NUGET_TOKEN}} --source https://api.nuget.org/v3/index.json + dotnet nuget push *.nupkg --skip-duplicate --api-key ${{ steps.nugetLogin.outputs.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json - name: Github Release shell: bash env: