Skip to content

Commit 283ee31

Browse files
randleeclaude
andcommitted
fix: Add OIDC token retrieval for NuGet Trusted Publishing
dotnet nuget push doesn't automatically use OIDC tokens. Need to manually retrieve the token and pass it as --api-key. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 99b5206 commit 283ee31

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

.github/workflows/publish.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,15 @@ jobs:
4343
echo "Package ID: Rand.MDTool"
4444
echo "Version: $(grep -oP '(?<=<Version>)[^<]+' src/MDTool/MDTool.csproj)"
4545
46+
- name: Get OIDC token
47+
id: oidc
48+
run: |
49+
OIDC_TOKEN=$(curl -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=api://AzureADTokenExchange" | jq -r '.value')
50+
echo "::add-mask::$OIDC_TOKEN"
51+
echo "token=$OIDC_TOKEN" >> $GITHUB_OUTPUT
52+
4653
- name: Publish to NuGet
47-
run: dotnet nuget push ./nupkg/*.nupkg --source https://api.nuget.org/v3/index.json --skip-duplicate
54+
run: dotnet nuget push ./nupkg/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ steps.oidc.outputs.token }} --skip-duplicate
4855

4956
- name: Upload package as artifact
5057
uses: actions/upload-artifact@v4

0 commit comments

Comments
 (0)