Skip to content

Commit 100cbea

Browse files
feat(actions): add nuget trusted publishing (#1694)
1 parent bf69197 commit 100cbea

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

.github/workflows/build.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,26 +308,40 @@ jobs:
308308
needs: [ build_core_and_testing, build_analyzers, build_refactorings, build_code_fixes ]
309309
runs-on: ubuntu-24.04
310310
if: github.ref_type == 'tag' && startsWith(github.ref_name, 'v')
311+
permissions:
312+
id-token: write
311313
steps:
312314
- uses: actions/download-artifact@v4
313315
with:
314316
pattern: nuget_*
315317
path: nuget
316318
merge-multiple: true
317-
- run: dotnet nuget push "*.nupkg" -k ${{ secrets.NUGET_API_KEY }} -s "https://api.nuget.org/v3/index.json" --skip-duplicate
319+
- name: NuGet login
320+
uses: NuGet/login@v1
321+
id: nuget-login
322+
with:
323+
user: ${{ secrets.NUGET_USER }}
324+
- run: dotnet nuget push "*.nupkg" -k ${{ steps.nuget-login.outputs.NUGET_API_KEY }} -s "https://api.nuget.org/v3/index.json" --skip-duplicate
318325
working-directory: nuget
319326

320327
publish_cli_nuget_packages:
321328
needs: [ build_core_cli, build_framework_cli ]
322329
runs-on: ubuntu-24.04
323330
if: github.ref_type == 'tag' && startsWith(github.ref_name, 'cli-v')
331+
permissions:
332+
id-token: write
324333
steps:
325334
- uses: actions/download-artifact@v4
326335
with:
327336
pattern: nuget_*
328337
path: nuget
329338
merge-multiple: true
330-
- run: dotnet nuget push "*.nupkg" -k ${{ secrets.NUGET_API_KEY }} -s "https://api.nuget.org/v3/index.json" --skip-duplicate
339+
- name: NuGet login
340+
uses: NuGet/login@v1
341+
id: nuget-login
342+
with:
343+
user: ${{ secrets.NUGET_USER }}
344+
- run: dotnet nuget push "*.nupkg" -k ${{ steps.nuget-login.outputs.NUGET_API_KEY }} -s "https://api.nuget.org/v3/index.json" --skip-duplicate
331345
working-directory: nuget
332346

333347
publish_vs_code_extension:

0 commit comments

Comments
 (0)