Skip to content

Commit be797de

Browse files
committed
Switch to nuget OIDC publishing (#3764)
1 parent 6ea26a1 commit be797de

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

.github/workflows/build.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ on:
1010
- v*
1111
pull_request:
1212

13+
permissions:
14+
contents: read
15+
id-token: write # required for GitHub OIDC
16+
1317
env:
1418
postgis_version: 3
1519
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
@@ -160,6 +164,8 @@ jobs:
160164
needs: build
161165
runs-on: ubuntu-24.04
162166
if: github.event_name == 'push' && startsWith(github.repository, 'npgsql/') && needs.build.outputs.is_release == 'true'
167+
permissions:
168+
id-token: write # enable GitHub OIDC token issuance for this job
163169
environment: nuget.org
164170

165171
steps:
@@ -180,6 +186,13 @@ jobs:
180186

181187
# TODO: Create a release
182188

189+
# Get a short-lived NuGet API key
190+
- name: NuGet login (OIDC)
191+
uses: NuGet/login@v1
192+
id: login
193+
with:
194+
user: ${{ secrets.NUGET_USER }}
195+
183196
- name: Publish to nuget.org
184-
run: dotnet nuget push "*.nupkg" --api-key ${{ secrets.NUGET_ORG_API_KEY }} --source https://api.nuget.org/v3/index.json
197+
run: dotnet nuget push "*.nupkg" --api-key ${{ steps.login.outputs.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json
185198
working-directory: nupkgs

0 commit comments

Comments
 (0)