From 184a339f5bb65ca7085e9718fe39ce6965d50d2a Mon Sep 17 00:00:00 2001 From: itvi-1234 Date: Tue, 1 Dec 2026 12:21:21 +0530 Subject: [PATCH] Approve staged npm releases on npmjs.com and add trust with the next release The publishing setup card now points to Staged Packages on npmjs.com instead of the stage id commands. A new package no longer gets the npm trust command right after its first release: npm drops a trusted publisher that is not used within 2 days, and the card on the pull request with the next release gives the command. --- .../extension-bindings/ci/publish_setup.py | 24 +++++++------------ .../ci/test_publish_setup.py | 6 +++-- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/tooling/extension-bindings/ci/publish_setup.py b/tooling/extension-bindings/ci/publish_setup.py index 9c70963..aade216 100644 --- a/tooling/extension-bindings/ci/publish_setup.py +++ b/tooling/extension-bindings/ci/publish_setup.py @@ -9,7 +9,7 @@ yet will be published after the merge, so it is looked up on that registry: npm A package that is not on npm gets its first release staged by the publish - workflow, and a maintainer approves it. A package whose only version is + workflow, and a maintainer approves it on npmjs.com. A package whose only version is the staged placeholder is still waiting for that approval. A package whose latest version was not published by trusted publishing has no trusted publisher yet, so the publish workflow would get a 404; the card @@ -174,14 +174,9 @@ def card(findings: list[Finding]) -> str: "#### npm: approve the staged first release", "", f"{bold(names)} {'has' if len(names) == 1 else 'have'} a staged first release that nobody approved, " - "so the package does not exist on npm yet. Find the stage id and approve it (asks for 2FA):", - "", - "```sh", - *[f"npm stage list {name}" for name in names], - "npm stage approve ", - "```", - "", - "Then add its trusted publisher with the command in the next step.", + "so the package does not exist on npm yet. On npmjs.com, open **Staged Packages** and approve " + f"{'it' if len(names) == 1 else 'each one'} (asks for 2FA). Then add the trusted publisher with the " + "command in the next step.", ] trust = by_state.get(NPM_NO_TRUST, []) + by_state.get(NPM_STAGED, []) if trust: @@ -206,14 +201,11 @@ def card(findings: list[Finding]) -> str: "#### npm: new packages, nothing to do before the merge", "", f"{bold(names)} {'is' if len(names) == 1 else 'are'} not on npm yet. The publish workflow stages the " - "first release with the stage-only token. After that run, approve it and add the trusted publisher, " - "so later releases need no token:", + "first release with the stage-only token. After that run, open **Staged Packages** on npmjs.com and " + f"approve {'it' if len(names) == 1 else 'each one'} (asks for 2FA).", "", - "```sh", - *[f"npm stage list {name}" for name in names], - "npm stage approve ", - trust_command(names), - "```", + "Do not add the trusted publisher yet: npm drops one that is not used within 2 days. The card on the " + "pull request with the next release gives the command.", ] rest = [ f"- **{finding.package.name}** {finding.package.version}: " diff --git a/tooling/extension-bindings/ci/test_publish_setup.py b/tooling/extension-bindings/ci/test_publish_setup.py index dad8f74..6ed9e52 100644 --- a/tooling/extension-bindings/ci/test_publish_setup.py +++ b/tooling/extension-bindings/ci/test_publish_setup.py @@ -93,11 +93,13 @@ def test_each_state_gets_its_steps(self) -> None: self.assertTrue(text.startswith(script.MARKER)) self.assertIn("| PyPI Project Name | example-new (one publisher each) |", text) self.assertIn("| Environment name | pypi |", text) - self.assertIn("npm stage list @example/waiting", text) + self.assertIn("Staged Packages", text) # The staged package needs a publisher once approved, like the untrusted one. self.assertIn("for p in @example/untrusted @example/waiting; do", text) self.assertIn("nothing to do before the merge", text) - self.assertIn("npm trust github @example/fresh", text) + # A new package gets its trusted publisher with its next release, not now. + self.assertNotIn("@example/fresh --file", text) + self.assertNotIn("npm stage", text) self.assertIn("No setup needed (1)", text) def test_nothing_to_do_says_so(self) -> None: