Skip to content

Commit c2cfe84

Browse files
Use NuGet Trusted Publishing (#3574)
Switch to using GitHub OIDC for pushing packages to NuGet.org with Trusted Publishing. - Resolves #3566. - Resolves https://github.com/domaindrivendev/Swashbuckle.AspNetCore/security/code-scanning/33.
1 parent 3afee04 commit c2cfe84

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

.github/workflows/build.yml

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,27 +65,27 @@ jobs:
6565
}
6666
6767
- name: Checkout code
68-
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
68+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
6969
with:
7070
filter: 'tree:0'
7171
persist-credentials: false
7272
show-progress: false
7373

7474
- name: Setup .NET SDKs
75-
uses: actions/setup-dotnet@2016bd2012dba4e32de620c46fe006a3ac9f0602 # v5.0.1
75+
uses: actions/setup-dotnet@2016bd2012dba4e32de620c46fe006a3ac9f0602 # v5.0.1
7676
with:
7777
dotnet-version: |
7878
8.0.x
7979
9.0.x
8080
8181
- name: Setup Node
82-
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
82+
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
8383
with:
8484
node-version: '24'
8585
package-manager-cache: false
8686

8787
- name: Setup .NET SDK
88-
uses: actions/setup-dotnet@2016bd2012dba4e32de620c46fe006a3ac9f0602 # v5.0.1
88+
uses: actions/setup-dotnet@2016bd2012dba4e32de620c46fe006a3ac9f0602 # v5.0.1
8989
id: setup-dotnet
9090

9191
- name: Install .NET tools
@@ -101,7 +101,7 @@ jobs:
101101
102102
- name: Upload Coverage Reports
103103
if: always()
104-
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
104+
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
105105
with:
106106
name: coverage-${{ runner.os }}
107107
path: ./artifacts/coverage
@@ -121,7 +121,7 @@ jobs:
121121
token: ${{ secrets.CODECOV_TOKEN }}
122122

123123
- name: Generate SBOM
124-
uses: anchore/sbom-action@fbfd9c6c189226748411491745178e0c2017392d # v0.20.10
124+
uses: anchore/sbom-action@fbfd9c6c189226748411491745178e0c2017392d # v0.20.10
125125
if: runner.os == 'Windows'
126126
with:
127127
artifact-name: Swashbuckle.AspNetCore.spdx.json
@@ -142,7 +142,7 @@ jobs:
142142
./artifacts/package/release/*
143143
144144
- name: Publish NuGet packages
145-
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
145+
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
146146
if: ${{ !cancelled() }}
147147
with:
148148
name: packages-${{ runner.os }}
@@ -165,12 +165,12 @@ jobs:
165165
steps:
166166

167167
- name: Download packages
168-
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
168+
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
169169
with:
170170
name: packages-Windows
171171

172172
- name: Setup .NET SDK
173-
uses: actions/setup-dotnet@2016bd2012dba4e32de620c46fe006a3ac9f0602 # v5.0.1
173+
uses: actions/setup-dotnet@2016bd2012dba4e32de620c46fe006a3ac9f0602 # v5.0.1
174174
with:
175175
dotnet-version: ${{ needs.build.outputs.dotnet-sdk-version }}
176176

@@ -225,12 +225,12 @@ jobs:
225225
steps:
226226

227227
- name: Download packages
228-
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
228+
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
229229
with:
230230
name: packages-Windows
231231

232232
- name: Setup .NET SDK
233-
uses: actions/setup-dotnet@2016bd2012dba4e32de620c46fe006a3ac9f0602 # v5.0.1
233+
uses: actions/setup-dotnet@2016bd2012dba4e32de620c46fe006a3ac9f0602 # v5.0.1
234234
with:
235235
dotnet-version: ${{ needs.build.outputs.dotnet-sdk-version }}
236236

@@ -253,21 +253,30 @@ jobs:
253253
name: NuGet.org
254254
url: https://www.nuget.org/profiles/domaindrivendev
255255

256+
permissions:
257+
id-token: write
258+
256259
steps:
257260

258261
- name: Download packages
259-
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
262+
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
260263
with:
261264
name: packages-Windows
262265

263266
- name: Setup .NET SDK
264-
uses: actions/setup-dotnet@2016bd2012dba4e32de620c46fe006a3ac9f0602 # v5.0.1
267+
uses: actions/setup-dotnet@2016bd2012dba4e32de620c46fe006a3ac9f0602 # v5.0.1
265268
with:
266269
dotnet-version: ${{ needs.build.outputs.dotnet-sdk-version }}
267270

271+
- name: NuGet log in
272+
uses: NuGet/login@d22cc5f58ff5b88bf9bd452535b4335137e24544 # v1.1.0
273+
id: nuget-login
274+
with:
275+
user: ${{ secrets.NUGET_USER }}
276+
268277
- name: Push NuGet packages to NuGet.org
269278
env:
270-
API_KEY: ${{ secrets.NUGET_TOKEN }}
279+
API_KEY: ${{ steps.nuget-login.outputs.NUGET_API_KEY }}
271280
PACKAGE_VERSION: ${{ needs.build.outputs.package-version }}
272281
SOURCE: https://api.nuget.org/v3/index.json
273282
run: |

0 commit comments

Comments
 (0)