Skip to content

Commit f914ffd

Browse files
hahn-kevclaude
andcommitted
Migrate NuGet publishing to trusted publishing (OIDC)
Replace the long-lived NuGet API key secret with short-lived, OIDC-issued credentials via NuGet trusted publishing: - Add id-token: write permission for GitHub OIDC token issuance - Add a NuGet/login@v1 step that exchanges the OIDC token for a short-lived API key (username from the NUGET_USER secret) - Push using the short-lived key instead of secrets.SILLSDEV_PUBLISH_NUGET_ORG The login step currently runs on every build (no gating condition) to validate the trusted publishing policy end-to-end; it will be restored to run only on publish once confirmed working. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 78cb077 commit f914ffd

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

.github/workflows/nuget-ci-cd.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ jobs:
1212
build:
1313
permissions:
1414
packages: write
15+
id-token: write # enable GitHub OIDC token issuance for NuGet trusted publishing
1516
runs-on: ubuntu-latest
1617

1718
steps:
@@ -48,6 +49,12 @@ jobs:
4849
name: nuget-packages
4950
path: src/artifacts/package/release/*nupkg
5051

52+
- name: NuGet login
53+
id: nuget-login
54+
uses: NuGet/login@v1
55+
with:
56+
user: ${{ secrets.NUGET_USER }}
57+
5158
- name: Publish package to NuGet.org
5259
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
5360
shell: bash
@@ -83,4 +90,4 @@ jobs:
8390
--source https://api.nuget.org/v3/index.json
8491
done
8592
env:
86-
NUGET_API_KEY: ${{ secrets.SILLSDEV_PUBLISH_NUGET_ORG }}
93+
NUGET_API_KEY: ${{ steps.nuget-login.outputs.NUGET_API_KEY }}

0 commit comments

Comments
 (0)