-
-
Notifications
You must be signed in to change notification settings - Fork 129
Switch NuGet publishing to trusted publishing #6573
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,6 +26,9 @@ jobs: | |
| os: [ubuntu-latest, windows-latest, macos-latest] | ||
| fail-fast: false | ||
| runs-on: ${{ matrix.os }} | ||
| permissions: | ||
| contents: write | ||
| id-token: write | ||
|
|
||
| steps: | ||
| - name: Free Disk Space (Ubuntu) | ||
|
|
@@ -151,12 +154,19 @@ jobs: | |
| core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env['ACTIONS_RUNTIME_TOKEN']); | ||
| core.exportVariable('ACTIONS_RESULTS_URL', process.env['ACTIONS_RESULTS_URL']); | ||
|
|
||
| - name: NuGet login | ||
| if: ${{ github.ref == 'refs/heads/main' && github.event.inputs.publish-packages == 'true' && matrix.os == 'ubuntu-latest' }} | ||
| uses: NuGet/login@v1 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
How this was verified: The publishing step references the mutable Knowledge Base Used: Build and CI |
||
| id: login | ||
| with: | ||
| user: ${{ secrets.NUGET_USER }} | ||
|
|
||
| - name: Run Pipeline | ||
| uses: ./.github/actions/execute-pipeline | ||
| with: | ||
| admin-token: ${{ secrets.ADMIN_TOKEN }} | ||
| environment: ${{ github.ref == 'refs/heads/main' && 'Production' || 'Development' }} | ||
| nuget-apikey: ${{ secrets.NUGET__APIKEY }} | ||
| nuget-apikey: ${{ steps.login.outputs.NUGET_API_KEY }} | ||
| publish-packages: ${{ (github.event.inputs.publish-packages || false) && matrix.os == 'ubuntu-latest' }} | ||
|
|
||
| - name: Upload Diagnostic Logs | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The job-level
contents: writeandid-token: writepermissions apply to pull-request, non-publishing, Windows, and macOS executions even though OIDC login and release operations are restricted to the main/Ubuntu publishing path. Scoping these capabilities to a dedicated publishing job would reduce the impact of compromised actions or unintended pipeline behavior.How this was verified: The permissions are assigned to the matrix job, while the OIDC-dependent login is gated to main, publishing enabled, and Ubuntu.
Knowledge Base Used: Build and CI
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!