Skip to content

Commit b07a0f6

Browse files
claudeReefact
authored andcommitted
ci: read NUGET_USER from a repository variable, not a secret
The nuget.org account name the trusted-publishing login authenticates as is a public profile name, not a credential: the API key it exchanges the OIDC token for is what must stay secret, and that key never leaves the job. Storing the username in Actions secrets bought no confidentiality and cost diagnosability — GitHub masks a secret in the logs, so a wrong or missing value showed up as an opaque login failure with the offending value redacted from the very output that would explain it. The value now lives in the repository variables, so the step reads it from the vars context. Documentation follows in both languages, in the release and dry-run pages, and the workflow comment records why it is a variable so it is not "hardened" back into a secret.
1 parent 5d53b76 commit b07a0f6

5 files changed

Lines changed: 20 additions & 13 deletions

File tree

.github/workflows/release.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,10 @@ jobs:
226226
227227
# Trusted publishing: exchange the job's OIDC token for a short-lived, single-use NuGet API key.
228228
# Requires a trusted publishing policy on nuget.org (owner Reefact / repo first-class-errors /
229-
# workflow release.yml) for each published package, and the NUGET_USER secret set to the nuget.org
230-
# account username (profile name, not the email address).
229+
# workflow release.yml) for each published package, and the NUGET_USER repository variable set to the
230+
# nuget.org account username (profile name, not the email address). It is a variable, not a secret: a
231+
# nuget.org profile name is public, and masking it as a secret only hid it from the logs that would
232+
# tell you when it is wrong.
231233
#
232234
# This login runs on EVERY trigger, INCLUDING a dry run: the OIDC token exchange is what validates the
233235
# trusted-publishing policy, so rehearsing it here makes a dry run fail red when the policy or
@@ -241,7 +243,7 @@ jobs:
241243
id: nuget-login
242244
uses: NuGet/login@8d196754b4036150537f80ac539e15c2f1028841 # v1
243245
with:
244-
user: ${{ secrets.NUGET_USER }}
246+
user: ${{ vars.NUGET_USER }}
245247

246248
- name: Push to NuGet
247249
if: github.event_name == 'push' || inputs.dry_run == false

doc/handwritten/for-maintainers/ReleaseDryRun.en.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ A dry run is *almost* free of side effects, with two things to be aware of:
7373
- **It performs the real NuGet OIDC login.** The trusted-publishing token
7474
exchange runs in a dry run — that is the point: it validates the nuget.org
7575
policy, so a dry run **fails red** if the trusted-publishing policy or the
76-
`NUGET_USER` secret is missing or misconfigured. It mints a short-lived,
77-
single-use API key that the dry run never spends (the push is skipped), so
78-
nothing is published.
76+
`NUGET_USER` repository variable is missing or misconfigured. It mints a
77+
short-lived, single-use API key that the dry run never spends (the push is
78+
skipped), so nothing is published.
7979
- **Nothing is published.** No package reaches nuget.org, and no GitHub Release
8080
or git tag is created.
8181
- **The packed `.nupkg` / `.snupkg` are uploaded as workflow-run artifacts**,

doc/handwritten/for-maintainers/ReleaseDryRun.fr.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ Un dry run est *presque* sans effet de bord, avec deux points à connaître :
7777
- **Il effectue le vrai login OIDC NuGet.** L'échange de jeton du trusted
7878
publishing s'exécute pendant un dry run — c'est le but : il valide la policy
7979
nuget.org, donc un dry run **échoue (rouge)** si la policy trusted-publishing
80-
ou le secret `NUGET_USER` est absent ou mal configuré. Il génère une clé API
81-
éphémère à usage unique que le dry run ne dépense jamais (le push est sauté),
82-
donc rien n'est publié.
80+
ou la variable de dépôt `NUGET_USER` est absente ou mal configurée. Il génère
81+
une clé API éphémère à usage unique que le dry run ne dépense jamais (le push
82+
est sauté), donc rien n'est publié.
8383
- **Rien n'est publié.** Aucun package n'atteint nuget.org, et aucune GitHub
8484
Release ni aucun tag Git n'est créé.
8585
- **Les `.nupkg` / `.snupkg` produits sont uploadés en artefacts de run**, que

doc/handwritten/for-maintainers/workflows/release.en.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,10 @@ deliberate:
115115
gated.** The token exchange is what validates the
116116
trusted-publishing policy, so a dry run fails red when the policy or
117117
`NUGET_USER` is missing. It mints a single-use key the dry run never spends.
118-
Requires a trusted-publishing policy on nuget.org and the `NUGET_USER` secret
119-
(the profile **username**, not the email).
118+
Requires a trusted-publishing policy on nuget.org and the `NUGET_USER`
119+
repository **variable** (the profile **username**, not the email). It is a
120+
variable, not a secret: a nuget.org profile name is public, and masking it
121+
only hid it from the logs that would tell you when it is wrong.
120122
- **The Release step pins `--target "$GITHUB_SHA"`.** On `workflow_dispatch` the
121123
tag does not exist yet and `gh` would otherwise create it from the default
122124
branch's latest state; pinning the SHA ties the tag, source archive and

doc/handwritten/for-maintainers/workflows/release.fr.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,11 @@ suivants est délibéré :
123123
cli) sont conditionnées.** L'échange de token est ce qui valide la
124124
policy trusted-publishing, donc un dry run échoue (rouge) quand la policy ou
125125
`NUGET_USER` est absent. Il génère une clé à usage unique que le dry run ne
126-
dépense jamais. Nécessite une policy trusted-publishing sur nuget.org et le
127-
secret `NUGET_USER` (le **nom d'utilisateur** du profil, pas l'e-mail).
126+
dépense jamais. Nécessite une policy trusted-publishing sur nuget.org et la
127+
**variable** de dépôt `NUGET_USER` (le **nom d'utilisateur** du profil, pas
128+
l'e-mail). C'est une variable, pas un secret : un nom de profil nuget.org est
129+
public, et le masquer ne faisait que le cacher des logs qui vous diraient
130+
qu'il est faux.
128131
- **L'étape Release épingle `--target "$GITHUB_SHA"`.** Sur `workflow_dispatch` le
129132
tag n'existe pas encore et `gh` le créerait sinon depuis le dernier état de la
130133
branche par défaut ; épingler le SHA lie le tag, l'archive source et les

0 commit comments

Comments
 (0)