Skip to content

Commit 2d853f1

Browse files
committed
Switch to nuget OIDC publishing (#3764)
1 parent 663e31a commit 2d853f1

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

.github/workflows/build.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ on:
1212

1313
permissions:
1414
contents: read
15+
id-token: write # required for GitHub OIDC
1516

1617
env:
1718
postgis_version: 3
@@ -177,6 +178,8 @@ jobs:
177178
needs: build
178179
runs-on: ubuntu-22.04
179180
if: github.event_name == 'push' && startsWith(github.repository, 'npgsql/') && needs.build.outputs.is_release == 'true'
181+
permissions:
182+
id-token: write # enable GitHub OIDC token issuance for this job
180183
environment: nuget.org
181184

182185
steps:
@@ -197,6 +200,13 @@ jobs:
197200

198201
# TODO: Create a release
199202

203+
# Get a short-lived NuGet API key
204+
- name: NuGet login (OIDC)
205+
uses: NuGet/login@v1
206+
id: login
207+
with:
208+
user: ${{ secrets.NUGET_USER }}
209+
200210
- name: Publish to nuget.org
201-
run: dotnet nuget push "*.nupkg" --api-key ${{ secrets.NUGET_ORG_API_KEY }} --source https://api.nuget.org/v3/index.json
211+
run: dotnet nuget push "*.nupkg" --api-key ${{ steps.login.outputs.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json
202212
working-directory: nupkgs

0 commit comments

Comments
 (0)