ci: adopt NuGet trusted publishing - #530
Conversation
Bind the NuGet publishing job to the GitHub production environment, request OIDC id-token permissions, and exchange credentials through NuGet/login instead of repository API key secrets. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Dependency ReviewThe following issues were found:
License Issues.github/workflows/ci.yml
OpenSSF Scorecard
Scanned Files
|
There was a problem hiding this comment.
🟡 Changes recommended
The current workflow can still create tags/releases while silently skipping NuGet.org publishing if credentials aren’t issued, which can result in incomplete releases.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Updates the CI release workflow to publish NuGet packages via OIDC-based Trusted Publishing instead of using a long-lived NuGet API key, aligning releases with GitHub Environments for stronger controls.
Changes:
- Bind the
releasejob to theproductionenvironment. - Add
id-token: writepermission to enable OIDC token exchange. - Replace
secrets.NUGET_API_KEYusage withNuGet/login@v1and its temporaryNUGET_API_KEYoutput.
File summaries
| File | Description |
|---|---|
.github/workflows/ci.yml |
Updates the release job to use GitHub Environment + OIDC (NuGet/login@v1) for NuGet.org publishing. |
Review details
Suppressed comments (1)
.github/workflows/ci.yml:312
- If
NuGet/login@v1does not issue a token (e.g., trusted publishing not fully configured yet), this job will still succeed and create a tag/GitHub Release while skipping the NuGet.org publish. For thepush-to-mainrelease job, it’s safer to fail fast so you don’t ship a release without the NuGet package.
run: |
if [ -n "$NUGET_API_KEY" ]; then
dotnet nuget push ./artifacts/*.nupkg \
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 90 | ||
| environment: production | ||
| permissions: | ||
| contents: write | ||
| packages: write | ||
| id-token: write |
Code Coverage |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #530 +/- ##
=========================================
Coverage 97.44% 97.44%
=========================================
Files 611 611
Lines 49926 49926
Branches 3230 34 -3196
=========================================
+ Hits 48649 48650 +1
+ Misses 1277 1276 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Test Results 12 files 12 suites 12m 1s ⏱️ Results for commit e70cd6c. |
🔍 PR Validation ResultsVersion: `` ✅ Validation Steps
📊 ArtifactsDry-run artifacts have been uploaded and will be available for 7 days. This comment was automatically generated by the PR validation workflow. |
Summary
productionGitHub environmentid-token: writewhere the NuGet publish job runsNuGet/login@v1OIDC-based temporary credentialsReal Behavior Proof
environment: production,uses: NuGet/login@v1, andid-token: write.