Skip to content

Commit a206014

Browse files
committed
Use Nuget Trusted Publishing for packahge publication
1 parent 83867ea commit a206014

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

.github/workflows/nuget-lib.yml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,16 @@ defaults:
66
run:
77
working-directory: Src
88

9+
permissions:
10+
id-token: write # required for Nuget Trusted Publishing
11+
912
jobs:
1013
publish:
11-
1214
runs-on: ubuntu-latest
13-
15+
16+
permissions:
17+
id-token: write # enable GitHub OIDC (OpenID Connect standard) token issuance for this job
18+
1419
steps:
1520
- uses: actions/checkout@v4
1621
- name: Setup .NET
@@ -25,5 +30,13 @@ jobs:
2530
run: dotnet test -c Release --no-build --framework net8.0
2631
- name: Pack nugets
2732
run: dotnet pack "./UUIDNext/UUIDNext.csproj" -c Release --no-build --output .
33+
34+
# Get a short-lived NuGet API key
35+
- name: NuGet login (OIDC → temp API key)
36+
uses: NuGet/login@v1
37+
id: login
38+
with:
39+
user: ${{ secrets.NUGET_USER }}
40+
2841
- name: Push to NuGet
29-
run: dotnet nuget push "UUIDNext.*.nupkg" --api-key ${{secrets.NUGET_API_KEY}} --skip-duplicate --source https://api.nuget.org/v3/index.json
42+
run: dotnet nuget push "UUIDNext.*.nupkg" --api-key ${{steps.login.outputs.NUGET_API_KEY}} --skip-duplicate --source https://api.nuget.org/v3/index.json

0 commit comments

Comments
 (0)