Skip to content

Commit b47c460

Browse files
committed
CHORE: Use OIDC (Trusted Publishing) instead of PAT for Nuget.
https://learn.microsoft.com/en-us/nuget/nuget-org/trusted-publishing
1 parent 25fdae8 commit b47c460

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

.github/workflows/release.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ on:
1414
jobs:
1515
build:
1616
runs-on: windows-latest
17+
permissions:
18+
contents: write # For release asset upload
19+
id-token: write # Required for OIDC token (NuGet Trusted Publishing)
1720
steps:
1821
- name: 🚚 Checkout code
1922
uses: actions/checkout@v4
@@ -61,6 +64,13 @@ jobs:
6164
./nupkg/*.nupkg
6265
./nupkg/*.snupkg
6366
67+
- name: 🔑 Login to NuGet (OIDC)
68+
id: nuget-login
69+
uses: nuget/login@v1
70+
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.dry_run != 'true')
71+
with:
72+
nuget-api-url: https://api.nuget.org/v3/index.json
73+
6474
- name: 🚀 Publish to NuGet
6575
shell: pwsh
6676
run: |
@@ -88,6 +98,6 @@ jobs:
8898
Write-Host "Publishing to NuGet..."
8999
foreach ($file in $nupkgFiles) {
90100
Write-Host "Publishing: $($file.FullName)"
91-
dotnet nuget push "$($file.FullName)" --api-key ${{ secrets.NUGET_API_KEY }} --source "https://api.nuget.org/v3/index.json" --skip-duplicate
101+
dotnet nuget push "$($file.FullName)" --api-key ${{ steps.nuget-login.outputs.NUGET_API_KEY }} --source "https://api.nuget.org/v3/index.json" --skip-duplicate
92102
}
93103
}

0 commit comments

Comments
 (0)