Skip to content

Commit aa23666

Browse files
committed
Use official NuGet/login action for Trusted Publishing
1 parent c0a35b8 commit aa23666

1 file changed

Lines changed: 6 additions & 15 deletions

File tree

.github/workflows/release.yml

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -84,25 +84,16 @@ jobs:
8484
- name: Pack
8585
run: dotnet pack --configuration Release -p:ReleaseVersion=${{ needs.validate.outputs.version }} --output ./artifacts
8686

87-
- name: Get NuGet API key (Trusted Publishing)
88-
id: nuget-auth
89-
run: |
90-
# Request OIDC token from GitHub
91-
OIDC_TOKEN=$(curl -s -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
92-
"$ACTIONS_ID_TOKEN_REQUEST_URL&audience=api://AzureADTokenExchange" | jq -r '.value')
93-
94-
# Exchange for NuGet API key
95-
API_KEY=$(curl -s -X POST https://api.nuget.org/v3/trusted-publish/token \
96-
-H "Content-Type: application/json" \
97-
-d "{\"oidcToken\": \"$OIDC_TOKEN\"}" | jq -r '.apiKey')
98-
99-
echo "::add-mask::$API_KEY"
100-
echo "api-key=$API_KEY" >> $GITHUB_OUTPUT
87+
- name: NuGet login (Trusted Publishing)
88+
uses: nuget/login@v1
89+
id: nuget-login
90+
with:
91+
user: ${{ secrets.NUGET_USER }}
10192

10293
- name: Push to NuGet
10394
run: |
10495
dotnet nuget push ./artifacts/*.nupkg \
105-
--api-key ${{ steps.nuget-auth.outputs.api-key }} \
96+
--api-key ${{ steps.nuget-login.outputs.nuget-api-key }} \
10697
--source https://api.nuget.org/v3/index.json \
10798
--skip-duplicate
10899

0 commit comments

Comments
 (0)