Skip to content

Commit 0454778

Browse files
authored
Merge pull request #1277 from micheloliveira-com/feature/nuget-trusted-publishing
feat(actions): add nuget trusted publishing
2 parents d9f1d87 + 6af09f0 commit 0454778

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

.github/workflows/release.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,13 @@ jobs:
1818
permissions:
1919
actions: read
2020
contents: write
21-
id-token: write # Required for Azure CLI Login
21+
id-token: write # Required for Azure / NuGet CLI Login
2222
steps:
2323
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
2424

2525
- name: ⚙️ Initialization
2626
shell: pwsh
2727
run: |
28-
if ('${{ secrets.NUGET_API_KEY }}') {
29-
Write-Host "NUGET_API_KEY secret detected. NuGet packages will be pushed."
30-
echo "NUGET_API_KEY_DEFINED=true" >> $env:GITHUB_ENV
31-
}
32-
3328
if ('${{ secrets.NPM_API_KEY }}') {
3429
Write-Host "NPM_API_KEY secret detected. NPM packages will be pushed."
3530
echo "NPM_API_KEY_DEFINED=true" >> $env:GITHUB_ENV
@@ -115,9 +110,14 @@ jobs:
115110
gh release -R ${{ github.repository }} upload "${{ github.ref_name }}" $_.FullName
116111
}
117112
113+
- name: 🪪 Authorize NuGet package push
114+
uses: NuGet/login@v1
115+
id: nuget-login
116+
with:
117+
user: ${{ secrets.NUGET_USER }}
118+
118119
- name: 🚀 Push NuGet packages
119-
run: dotnet nuget push ${{ runner.temp }}\deployables\*.nupkg --source https://api.nuget.org/v3/index.json -k '${{ secrets.NUGET_API_KEY }}'
120-
if: ${{ env.NUGET_API_KEY_DEFINED == 'true' }}
120+
run: dotnet nuget push ${{ runner.temp }}\deployables\*.nupkg --source https://api.nuget.org/v3/index.json -k '${{ steps.nuget-login.outputs.NUGET_API_KEY }}'
121121

122122
- name: 🚀 Push NPM packages
123123
shell: pwsh

0 commit comments

Comments
 (0)