From 8072b4cc924f26cb76626f31aa398db707d1af0c Mon Sep 17 00:00:00 2001 From: Tom Longhurst <30480171+thomhurst@users.noreply.github.com> Date: Sun, 9 Aug 2026 13:47:45 +0100 Subject: [PATCH] Switch NuGet publishing to trusted publishing --- .github/workflows/dotnet.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 654f1e1..c913536 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -19,6 +19,9 @@ jobs: modularpipeline: environment: ${{ github.ref == 'refs/heads/main' && 'Production' || 'Pull Requests' }} runs-on: ubuntu-latest + permissions: + contents: write + id-token: write steps: - uses: actions/checkout@v7 @@ -33,11 +36,18 @@ jobs: 8.0.x 9.0.x 10.0.x + - name: NuGet login + if: ${{ github.ref == 'refs/heads/main' && github.event.inputs.publish-packages == 'true' }} + uses: NuGet/login@v1 + id: login + with: + user: ${{ secrets.NUGET_USER }} + - name: Run Pipeline run: dotnet run -c Release working-directory: "EnumerableAsyncProcessor.Pipeline" env: DOTNET_ENVIRONMENT: ${{ github.ref == 'refs/heads/main' && 'Production' || 'Development' }} - NuGet__ApiKey: ${{ github.ref == 'refs/heads/main' && secrets.NuGet__ApiKey || null }} + NuGet__ApiKey: ${{ steps.login.outputs.NUGET_API_KEY }} PULL_REQUEST_BRANCH: ${{ github.event.pull_request.head.ref }} PUBLISH_PACKAGES: ${{ github.event.inputs.publish-packages }}