Skip to content

Commit 714bf5d

Browse files
authored
ci(nuget): use Trusted Publishing auth (#1578)
Issue: DEVOPS-3949
1 parent 4304148 commit 714bf5d

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

.github/workflows/publish-libraries.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ jobs:
140140
if: ${{ needs.preflight.outputs.dry_run == 'false' }}
141141
needs: [preflight, nuget-merge]
142142
runs-on: ubuntu-latest
143+
permissions:
144+
id-token: write
143145

144146
steps:
145147
- name: Download NuGet packages artifact
@@ -148,6 +150,12 @@ jobs:
148150
name: nupkg
149151
path: nuget-packages
150152

153+
- name: NuGet login (OIDC)
154+
id: nuget-login
155+
uses: NuGet/login@v1
156+
with:
157+
user: ${{ secrets.NUGET_BOT_USERNAME }}
158+
151159
- name: Publish to nuget.org
152160
run: |
153161
Set-PSDebug -Trace 1
@@ -161,7 +169,7 @@ jobs:
161169
'push',
162170
"$File",
163171
'--api-key',
164-
'${{ secrets.NUGET_API_KEY }}',
172+
'${{ steps.nuget-login.outputs.NUGET_API_KEY }}',
165173
'--source',
166174
'https://api.nuget.org/v3/index.json',
167175
'--skip-duplicate'

.github/workflows/release.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,8 @@ jobs:
507507
if: ${{ needs.preflight.outputs.skip-publishing == 'false' || inputs.dry-run }}
508508
needs: [preflight]
509509
runs-on: ubuntu-latest
510+
permissions:
511+
id-token: write
510512

511513
steps:
512514
- name: Download jetsocat-nuget artifact
@@ -515,6 +517,12 @@ jobs:
515517
env:
516518
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
517519

520+
- name: NuGet login (OIDC)
521+
id: nuget-login
522+
uses: NuGet/login@v1
523+
with:
524+
user: ${{ secrets.NUGET_BOT_USERNAME }}
525+
518526
- name: Publish Jetsocat NuGet package
519527
run: |
520528
Set-PSDebug -Trace 1
@@ -528,7 +536,7 @@ jobs:
528536
'push',
529537
"$($Package.FullName)",
530538
'--api-key',
531-
'${{ secrets.NUGET_API_KEY }}',
539+
'${{ steps.nuget-login.outputs.NUGET_API_KEY }}',
532540
'--source',
533541
'https://api.nuget.org/v3/index.json',
534542
'--skip-duplicate'

0 commit comments

Comments
 (0)