From 4b2d817f21e7fedf5ecdbe4fcf5ba1fcd244d8bb Mon Sep 17 00:00:00 2001 From: stesee <168659+stesee@users.noreply.github.com> Date: Mon, 2 Nov 2026 05:55:39 +0000 Subject: [PATCH] Use NuGet Trusted Publishing for nugettest.org push instead of API key --- .github/workflows/dotnet.yml | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index c8251e59..877052af 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -76,15 +76,28 @@ jobs: if: github.ref == 'refs/heads/main' runs-on: ubuntu-latest needs: build + permissions: + contents: read + id-token: write # NuGet Trusted Publishing (OIDC) + env: + NUGET_TEST_USER: ${{ secrets.NUGET_TEST_USER }} steps: - uses: actions/checkout@v7 + if: env.NUGET_TEST_USER != '' - name: Download build artifacts + if: env.NUGET_TEST_USER != '' uses: actions/download-artifact@v8 with: name: build-artifacts + - name: NuGet test login (Trusted Publishing) + if: env.NUGET_TEST_USER != '' + uses: NuGet/login@v1 + id: nugetLogin + with: + user: ${{ secrets.NUGET_TEST_USER }} + token-service-url: https://int.nugettest.org/api/v2/token + audience: https://int.nugettest.org - name: NugetPush - env: - NUGET_TOKEN_EXISTS: ${{ secrets.NUGET_TEST_TOKEN }} - if: env.NUGET_TOKEN_EXISTS != '' + if: env.NUGET_TEST_USER != '' run: | - dotnet nuget push *.nupkg --skip-duplicate --api-key ${{secrets.NUGET_TEST_TOKEN}} --source https://apiint.nugettest.org/v3/index.json + dotnet nuget push *.nupkg --skip-duplicate --api-key ${{ steps.nugetLogin.outputs.NUGET_API_KEY }} --source https://apiint.nugettest.org/v3/index.json