File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ permissions:
1212 packages : write
1313 checks : write
1414 pull-requests : write
15+ id-token : write # Required for NuGet trusted publishing (OIDC)
1516
1617jobs :
1718 build :
3334 - name : Publish NuGet package
3435 if : github.event_name == 'release'
3536 run : |
36- dotnet nuget push bin/artifacts/**/*.nupkg --api-key "${{ secrets.NUGET_APIKEY }}" --source "https://api.nuget.org/v3/index.json" --skip-duplicate
37+ OIDC_TOKEN=$(curl --silent --show-error --fail-with-body \
38+ --url "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=api://AzureADTokenExchange" \
39+ --header "Authorization: Bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
40+ | jq --raw-output '.value')
41+ API_KEY=$(curl --silent --show-error --fail-with-body \
42+ --request POST \
43+ --url "https://api.nuget.org/v1/authentication/authenticate" \
44+ --header "Content-Type: application/json" \
45+ --data "{\"oidcToken\": \"$OIDC_TOKEN\"}" \
46+ | jq --raw-output '.apiKey')
47+ dotnet nuget push bin/artifacts/**/*.nupkg --api-key "$API_KEY" --source "https://api.nuget.org/v3/index.json" --skip-duplicate
You can’t perform that action at this time.
0 commit comments