Skip to content

Commit bc02278

Browse files
Publish to NuGet.org with trusted publishing (#674)
The release job exchanges a GitHub OIDC token for a short-lived NuGet.org API key through NuGet/login, instead of using the long-lived NUGET_API_KEY secret. Closes #669. (cherry picked from commit d60414e)
1 parent 017ba00 commit bc02278

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ jobs:
4040
release:
4141
needs: build
4242
runs-on: ubuntu-latest
43+
permissions:
44+
contents: read
45+
id-token: write
4346
steps:
4447
- name: checkout code
4548
uses: actions/checkout@v6.0.0
@@ -69,11 +72,17 @@ jobs:
6972
dotnet nuget push ./nugets/*.nupkg --source https://f.feedz.io/radical-framework/pre-releases/nuget/index.json --api-key ${{ secrets.FEEDZ_API_KEY }}
7073
echo "Pushing Symbols to Feedz.io"
7174
dotnet nuget push ./nugets/*.snupkg --source https://f.feedz.io/radical-framework/pre-releases/nuget/index.json --api-key ${{ secrets.FEEDZ_API_KEY }}
75+
- name: NuGet login
76+
id: nuget-login
77+
if: steps.check-tag-type.outputs.release-type == 'production'
78+
uses: NuGet/login@v1.2.0
79+
with:
80+
user: ${{ secrets.NUGET_USER }}
7281
- name: Deploy release to NuGet
7382
if: steps.check-tag-type.outputs.release-type == 'production'
7483
run: |
7584
echo "Tag is production"
7685
echo "Pushing package to NuGet.org"
77-
dotnet nuget push ./nugets/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }}
86+
dotnet nuget push ./nugets/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ steps.nuget-login.outputs.NUGET_API_KEY }}
7887
echo "Pushing Symbols to NuGet.org"
79-
dotnet nuget push ./nugets/*.snupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }}
88+
dotnet nuget push ./nugets/*.snupkg --source https://api.nuget.org/v3/index.json --api-key ${{ steps.nuget-login.outputs.NUGET_API_KEY }}

0 commit comments

Comments
 (0)