Skip to content

Commit 5ff8f46

Browse files
committed
Use repository variable for NuGet login
1 parent 65d9c93 commit 5ff8f46

5 files changed

Lines changed: 13 additions & 14 deletions

File tree

.github/workflows/release-codecs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464
uses: NuGet/login@v1
6565
id: nuget-login
6666
with:
67-
user: ${{ secrets.NUGET_USER }}
67+
user: ${{ vars.NUGET_USER }}
6868

6969
- name: Publish Codecs to NuGet
7070
run: dotnet nuget push ./artifacts/packages/ValidationPackage.Codecs.*.nupkg --api-key ${{ steps.nuget-login.outputs.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate

.github/workflows/release-model.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464
uses: NuGet/login@v1
6565
id: nuget-login
6666
with:
67-
user: ${{ secrets.NUGET_USER }}
67+
user: ${{ vars.NUGET_USER }}
6868

6969
- name: Publish Model to NuGet
7070
run: dotnet nuget push ./artifacts/packages/ValidationPackage.Model.*.nupkg --api-key ${{ steps.nuget-login.outputs.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate

.github/workflows/release-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ jobs:
2929
uses: NuGet/login@v1
3030
id: nuget-login
3131
with:
32-
user: ${{ secrets.NUGET_USER }}
32+
user: ${{ vars.NUGET_USER }}
3333
- name: push
3434
run: dotnet nuget push ./artifacts/packages/*.nupkg --api-key ${{ steps.nuget-login.outputs.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ When adding tests:
232232
successful policy can publish any NuGet package owned by that account. npm
233233
publishers are configured per scoped package and PyPI publishers per project,
234234
using the exact field matrix in `docs/operations/releases.md`.
235-
- All package publish jobs need `id-token: write` and the `release` environment. `NuGet/login` exchanges OIDC for a temporary key; never restore a long-lived `NUGET_KEY`. `NUGET_USER` is only the nuget.org profile name associated with the policy. Reusable publishers must read it directly from their job environment because GitHub cannot pass environment secrets through `workflow_call`.
235+
- All package publish jobs need `id-token: write` and the `release` environment. `NuGet/login` exchanges OIDC for a temporary key; never restore a long-lived `NUGET_KEY`. `NUGET_USER` is a repository Actions variable containing only the public nuget.org profile name associated with the policy. Repository variables remain available to same-repository reusable workflows without forwarding secrets.
236236
- A staged package marked for publication can be pushed to the production registry after checks pass.
237237
- Workflow actions should remain pinned to deliberate versions/commits. Preserve least-privilege permissions and never print secrets.
238238

docs/operations/releases.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,10 @@ versioned so consumers can opt into portable model conversion.
152152
Create a protected GitHub environment named `release` in both repositories.
153153
Add required reviewers and allow deployments from both `dev` and `release` so
154154
the manually dispatched package workflows can publish reviewed preview versions
155-
from `dev` as well as production versions from `release`. Store one environment
156-
secret, `NUGET_USER`, whose value is the nuget.org profile that owns the
157-
trusted-publishing policies (currently `Mutagene`),
158-
not an email address, GitHub username, organization name, or API key.
155+
from `dev` as well as production versions from `release`. Create one repository
156+
Actions variable, `NUGET_USER`, whose value is the nuget.org profile that owns
157+
the trusted-publishing policies (currently `Mutagene`), not an email address,
158+
GitHub username, organization name, or API key.
159159

160160
On nuget.org, select the personal account `Mutagene` as the policy owner and
161161
keep the NuGet packages owned by that account. NuGet policies are owner-wide:
@@ -174,10 +174,9 @@ only:
174174

175175
The Client and Interop policy names the called reusable workflow because that
176176
is the workflow NuGet observes in the `job_workflow_ref` claim. The reusable
177-
workflow reads `NUGET_USER` directly from its `release` environment; environment
178-
secrets cannot be passed through `workflow_call` by the caller. The four policy
179-
rows distinguish trusted workflow identities, but they do not create four
180-
package-level scopes.
177+
workflow reads the `NUGET_USER` repository variable directly, so no secret needs
178+
to be forwarded through `workflow_call`. The four policy rows distinguish
179+
trusted workflow identities, but they do not create four package-level scopes.
181180

182181
On npmjs.com, open each package's **Settings → Trusted Publisher**, select
183182
**GitHub Actions**, and enter:
@@ -230,8 +229,8 @@ workflows.
230229

231230
The publish jobs request `id-token: write`. `NuGet/login` exchanges OIDC for a
232231
temporary API key; npm and PyPI also exchange OIDC without repository tokens.
233-
Store only the nuget.org profile name as `NUGET_USER`, and do not restore a
234-
long-lived `NUGET_KEY`, npm token, or PyPI token.
232+
Store only the nuget.org profile name in the `NUGET_USER` repository Actions
233+
variable, and do not restore a long-lived `NUGET_KEY`, npm token, or PyPI token.
235234

236235
See the official registry instructions for
237236
[NuGet trusted publishing](https://learn.microsoft.com/nuget/nuget-org/trusted-publishing),

0 commit comments

Comments
 (0)