Skip to content

Commit b50736b

Browse files
JusterZhuclaude
andcommitted
fix: use official NuGet/login@v1 for Trusted Publishing
The manual OIDC token fetch didn't work because NuGet.org requires a two-step exchange: GitHub OIDC token → NuGet.org temp API key → push. Using NuGet/login@v1 handles this correctly. Also removes jq dependency (no longer needed). Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 976e31d commit b50736b

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

.github/workflows/publish-nuget.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,17 @@ jobs:
8383
--generate-notes \
8484
--verify-tag
8585
86-
- name: Push NuGet package to NuGet.org (Trusted Publishing via OIDC)
86+
- name: NuGet login via Trusted Publishing (OIDC → temp API key)
87+
if: ${{ inputs.push-to-nuget == true }}
88+
id: nuget-login
89+
uses: NuGet/login@v1
90+
with:
91+
user: ${{ secrets.NUGET_USER }}
92+
93+
- name: Push NuGet package to NuGet.org
8794
if: ${{ inputs.push-to-nuget == true }}
8895
run: |
89-
# Strip default audience from the request URL and set 'nuget' as the sole audience
90-
BASE_URL="${ACTIONS_ID_TOKEN_REQUEST_URL%%\?*}"
91-
ID_TOKEN=$(curl -sSL -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
92-
"${BASE_URL}?audience=nuget" | jq -r '.value')
9396
dotnet nuget push artifacts/*.nupkg \
9497
--source https://api.nuget.org/v3/index.json \
95-
--api-key "$ID_TOKEN" \
98+
--api-key "${{ steps.nuget-login.outputs.NUGET_API_KEY }}" \
9699
--skip-duplicate

0 commit comments

Comments
 (0)