Skip to content

Commit 976e31d

Browse files
JusterZhuclaude
andcommitted
fix: set correct OIDC audience for NuGet Trusted Publishing
The default ACTIONS_ID_TOKEN_REQUEST_URL has a built-in audience (sts.windows.net). Replace it with audience=nuget so the JWT token is accepted by NuGet.org's Trusted Publishing. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 7c152d8 commit 976e31d

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

.github/workflows/publish-nuget.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,10 @@ jobs:
8686
- name: Push NuGet package to NuGet.org (Trusted Publishing via OIDC)
8787
if: ${{ inputs.push-to-nuget == true }}
8888
run: |
89+
# Strip default audience from the request URL and set 'nuget' as the sole audience
90+
BASE_URL="${ACTIONS_ID_TOKEN_REQUEST_URL%%\?*}"
8991
ID_TOKEN=$(curl -sSL -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
90-
"$ACTIONS_ID_TOKEN_REQUEST_URL&audience=nuget" | jq -r '.value')
92+
"${BASE_URL}?audience=nuget" | jq -r '.value')
9193
dotnet nuget push artifacts/*.nupkg \
9294
--source https://api.nuget.org/v3/index.json \
9395
--api-key "$ID_TOKEN" \

0 commit comments

Comments
 (0)