Skip to content

Commit 32a2bfb

Browse files
authored
Merge pull request #3062 from ERGO-Code/nuget-api-to-trusted
Nuget api key to trusted publishing
2 parents 68884b1 + b35c69e commit 32a2bfb

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

.github/workflows/build-nuget-package.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,10 @@ jobs:
208208
needs: [build_windows]
209209
environment:
210210
name: nuget
211+
permissions:
212+
id-token: write # enable GitHub OIDC token issuance for this job
211213

212-
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
214+
if: github.event_name == 'release'
213215
steps:
214216
- uses: actions/checkout@v6
215217
- uses: actions/setup-dotnet@v5
@@ -219,7 +221,12 @@ jobs:
219221
with:
220222
name: nuget
221223

224+
# Get a short-lived NuGet API key
225+
- name: NuGet login (OIDC → temp API key)
226+
uses: NuGet/login@v1
227+
id: login
228+
with:
229+
user: ${{ secrets.NUGET_USER }}
230+
222231
- name: Dotnet push
223-
run: dotnet nuget push "*.nupkg" --api-key ${{secrets.nuget_api_key}} --source https://api.nuget.org/v3/index.json
224-
# env:
225-
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
232+
run: dotnet nuget push "*.nupkg" --api-key ${{ steps.login.outputs.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json

0 commit comments

Comments
 (0)