Skip to content

Commit 18098b6

Browse files
ANcpLuaclaude
andcommitted
ci: pass NuGet/login OIDC api key to dotnet nuget push
The previous run got past authentication (NuGet/login@v1 exchanged the GitHub OIDC token for a short-lived NuGet.org API key) but then `dotnet nuget push` had no way to use that key and got 401: No API Key was provided and no API Key could be found for 'https://www.nuget.org/api/v2/package' error: Response status code does not indicate success: 401 NuGet/login@v1 exposes the key via outputs.NUGET_API_KEY. Give the auth step an `id`, plumb the output through an env var, and pass it to `dotnet nuget push --api-key`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 67918e8 commit 18098b6

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

.github/workflows/nuget-publish.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,18 @@ jobs:
8282
run: dotnet pack CreatePdf.NET/CreatePdf.NET.csproj --configuration Release --no-build --output ./nupkg -p:GeneratePackageOnBuild=false
8383

8484
- name: Authenticate with NuGet
85+
id: nuget-auth
8586
uses: NuGet/login@v1
8687
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
8788
with:
8889
user: ANcpLua
8990

9091
- name: Publish packages to NuGet.org
9192
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
93+
env:
94+
NUGET_API_KEY: ${{ steps.nuget-auth.outputs.NUGET_API_KEY }}
9295
run: |
9396
dotnet nuget push ./nupkg/*.nupkg \
9497
--source https://api.nuget.org/v3/index.json \
98+
--api-key "$NUGET_API_KEY" \
9599
--skip-duplicate

0 commit comments

Comments
 (0)