Skip to content

Commit e154280

Browse files
authored
ci: publish to NuGet via Trusted Publishing, not a long-lived key (#100)
The release job pushed all four Atypical.TechnicalAnalysis* packages with a NUGET_API_KEY repository secret. It now exchanges the GitHub OIDC token for a key valid ~1 hour (NuGet/login v1.2.0), so nothing long-lived is stored; the only remaining secret is NUGET_USER, the nuget.org profile name. permissions.id-token: write was already declared at workflow level, and the release job declares no permissions of its own, so it inherits it — no permission change was needed. The nuget.org policy must cover all four package ids. Note they are Atypical.* ids under a phmatray repository, so the policy belongs to whichever nuget.org account owns those ids, and names phmatray/TaLibStandard regardless.
1 parent 613d250 commit e154280

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

.github/workflows/ci-cd.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,23 @@ jobs:
177177
skip-commit: true
178178
output-file: false
179179

180+
# Trusted Publishing: no long-lived API key. The login step exchanges this workflow's OIDC
181+
# token (permissions.id-token: write, declared at workflow level and inherited by this job) for
182+
# a NuGet key valid ~1 hour, so it must stay adjacent to the push below. Requires a Trusted
183+
# Publishing policy on nuget.org covering all four Atypical.TechnicalAnalysis* ids, naming this
184+
# repository and ci-cd.yml, plus the NUGET_USER secret (the nuget.org profile name).
185+
- name: NuGet login (OIDC -> short-lived key)
186+
id: nuget-login
187+
if: steps.should_release.outputs.new_release == 'true'
188+
uses: NuGet/login@8d196754b4036150537f80ac539e15c2f1028841 # v1.2.0
189+
with:
190+
user: ${{ secrets.NUGET_USER }}
191+
180192
- name: Push to NuGet
181193
if: steps.should_release.outputs.new_release == 'true'
182194
run: |
183195
dotnet nuget push "./artifacts/*.nupkg" \
184-
--api-key "${{ secrets.NUGET_API_KEY }}" \
196+
--api-key "${{ steps.nuget-login.outputs.NUGET_API_KEY }}" \
185197
--source "https://api.nuget.org/v3/index.json" \
186198
--skip-duplicate
187199

0 commit comments

Comments
 (0)