Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 8 additions & 16 deletions tooling/extension-bindings/ci/publish_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 <stage-id>",
"```",
"",
"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:
Expand All @@ -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 <stage-id>",
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}: "
Expand Down
6 changes: 4 additions & 2 deletions tooling/extension-bindings/ci/test_publish_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down