Skip to content

Commit 4b1a9e0

Browse files
committed
Add GitHub Actions job to deploy to NuGet
1 parent d40a398 commit 4b1a9e0

1 file changed

Lines changed: 33 additions & 4 deletions

File tree

.github/workflows/ci.yml

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ env:
66
RELEASE_MODE: "Beta"
77
RUN_TESTS: "true"
88

9-
permissions:
10-
checks: write
11-
pull-requests: write
12-
139
concurrency:
1410
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
1511
cancel-in-progress: true
@@ -57,6 +53,9 @@ jobs:
5753
build-and-validate:
5854
name: "Build and Validate"
5955
runs-on: "windows-2025-vs2026"
56+
permissions:
57+
checks: write
58+
pull-requests: write
6059
defaults:
6160
run:
6261
shell: "pwsh"
@@ -128,6 +127,7 @@ jobs:
128127
action_fail: true
129128

130129
- name: "Publish Artifacts"
130+
id: "publish-artifacts-step"
131131
uses: "actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f" # v7.0.0
132132
if: ${{ !cancelled() }}
133133
with:
@@ -142,3 +142,32 @@ jobs:
142142
env:
143143
GITHUB_APP_ID: ${{ secrets.GITHUB_APP_ID }}
144144
GITHUB_APP_PRIVATE_KEY: ${{ secrets.GITHUB_APP_PRIVATE_KEY }}
145+
146+
outputs:
147+
artifact-id: ${{ steps.publish-artifacts-step.outputs.artifact-id }}
148+
149+
deploy-to-nuget:
150+
name: "Deploy to NuGet"
151+
needs: ["build-and-validate"]
152+
environment: "nuget.org"
153+
if: ${{ github.event_name == 'workflow_dispatch' }}
154+
runs-on: "ubuntu-latest"
155+
permissions:
156+
id-token: "write"
157+
defaults:
158+
run:
159+
shell: "pwsh"
160+
steps:
161+
- name: "Download Artifacts"
162+
uses: "actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c" # v8.0.1
163+
with:
164+
artifact-ids: ${{ needs.build-and-validate.outputs.artifact-id }}
165+
166+
- name: "NuGet login (OIDC → temp API key)"
167+
uses: "NuGet/login@d22cc5f58ff5b88bf9bd452535b4335137e24544" # v1
168+
id: "nuget-login"
169+
with:
170+
user: ${{ secrets.NUGET_USER }}
171+
172+
- name: "NuGet Push"
173+
run: "dotnet nuget push *.nupkg --api-key ${{ steps.nuget-login.outputs.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json"

0 commit comments

Comments
 (0)