Skip to content

ci(publish-npm): upgrade npm so OIDC Trusted Publishing works - #80

Merged
Yan Xue (yanxue06) merged 1 commit into
mainfrom
ci/npm-oidc-requires-npm11
May 22, 2026
Merged

ci(publish-npm): upgrade npm so OIDC Trusted Publishing works#80
Yan Xue (yanxue06) merged 1 commit into
mainfrom
ci/npm-oidc-requires-npm11

Conversation

@yanxue06

@yanxue06 Yan Xue (yanxue06) commented May 22, 2026

Copy link
Copy Markdown
Contributor

Problem

npm OIDC Trusted Publishing requires npm ≥ 11.5.1, but publish-npm runs on Node 20, which bundles npm 10.x. On npm 10 the OIDC publish step signs provenance (that's supported) but cannot authenticate tokenlessly — so it effectively runs an unauthenticated publish and fails:

🔒 Attempting publish via npm Trusted Publishing (OIDC, no token)...
npm error code E404
npm error 404 Not Found - PUT https://registry.npmjs.org/@photon-ai%2fcli - Not found
npm error 404  '@photon-ai/cli@0.3.2' is not in this registry.
⚠️ OIDC publish failed. Falling back to NPM token.

(Surfaced while onboarding @photon-ai/cli to trusted publishing — the trusted-publisher config was correct, but the publish could never authenticate via OIDC on npm 10.)

Fix

Install npm@latest after setup-node, before the publish steps, so the OIDC path can authenticate. ~10s added to the publish job; affects every repo that publishes through publish-npm.

Note

This is necessary but not always sufficient for a given package — the trusted publisher must also be configured on npmjs.com (GitHub org/user, repo, caller workflow filename, matching Allow npm publish).

🤖 Generated with Claude Code


View with Codesmith Autofix with Codesmith
Need help on this PR? Tag @codesmith with what you need. Autofix is disabled.

Summary by CodeRabbit

  • Chores
    • Improved npm package publishing reliability by ensuring npm version compatibility during the release process.

Review Change Stack

npm OIDC Trusted Publishing requires npm >= 11.5.1, but the publish job
runs on Node 20 which bundles npm 10.x. On npm 10 the OIDC publish step
signs provenance but cannot authenticate tokenlessly, so it falls through
to an unauthenticated publish and fails with E404 ("not in this
registry"). Install npm@latest after setup-node, before the publish
steps, so the OIDC path can actually authenticate.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 22, 2026 05:57
@coderabbitai

coderabbitai Bot commented May 22, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Add npm global upgrade step to the npm publishing composite action. Before OIDC Trusted Publishing, the action now upgrades npm to the latest version and logs the version to ensure compatibility with the tokenless publish flow on Node 20.

Changes

npm OIDC Publishing Setup

Layer / File(s) Summary
npm upgrade step for OIDC publishing
.github/blocks/publish-npm/action.yaml
Added a step that upgrades npm globally to latest and logs the version, executed before dependency install and build to support the subsequent OIDC Trusted Publishing attempt.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • photon-hq/buildspace#77: The npm upgrade prerequisite added in this PR directly supports the OIDC-first publishing flow with token fallback implemented in that PR, ensuring npm compatibility for tokenless publish attempts.

Poem

🐰 A tiny hop to upgrade the npm,
Before OIDC takes the lead,
Version logged with care and zeal,
Publishing flows smoothly indeed!
Building trust, line by line.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically identifies the main change: upgrading npm in the CI publish workflow to enable OIDC Trusted Publishing, which directly addresses the PR's primary objective.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ci/npm-oidc-requires-npm11

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

Copy link
Copy Markdown

📄 README may need an update

This PR introduces changes that might not be reflected in README.md.

Reason: README.md does not document the publish-command input now exposed by .github/blocks/publish-npm/action.yaml, so it is missing a public configuration option for the publish-npm block.

This is an automated check powered by AI. If the README is intentionally unchanged, feel free to ignore this.

@github-actions

Copy link
Copy Markdown

📚 Skills documentation may need an update

This PR introduces changes that might not be reflected in the skills documentation.

Reason: _skills-repo/skills/buildspace-ci-cd/SKILL.md still describes npm publishing as token-based only, but .github/blocks/publish-npm/action.yaml now supports npm Trusted Publishing via OIDC with npm-token as fallback, so the skill should document the new auth path and permission/config requirements.

This is an automated check powered by AI. If the skills are intentionally unchanged, feel free to ignore this.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
.github/blocks/publish-npm/action.yaml (1)

49-56: ⚡ Quick win

Keep the npm >= 11.5.1 claim, but pin the npm upgrade instead of using @latest.

The “npm >= 11.5.1 for OIDC Trusted Publishing” requirement is consistent with npm Trusted Publishing docs; your step’s logic is sound. To improve CI/CD reproducibility, avoid npm@latest drifting over time—pin to the minimum compatible version range instead.

Suggested change
-        npm install -g npm@latest
+        npm install -g npm@^11.5.1
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/blocks/publish-npm/action.yaml around lines 49 - 56, The "Upgrade
npm for OIDC Trusted Publishing" step currently installs npm@latest; change it
to pin a concrete compatible version (e.g., replace the install command in that
step with a pinned version like npm install -g npm@11.5.1 or a caret range such
as npm install -g npm@^11.5.1) so CI is reproducible while still meeting the npm
>= 11.5.1 requirement; keep the rest of the step (shell: bash and the version
echo) intact.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In @.github/blocks/publish-npm/action.yaml:
- Around line 49-56: The "Upgrade npm for OIDC Trusted Publishing" step
currently installs npm@latest; change it to pin a concrete compatible version
(e.g., replace the install command in that step with a pinned version like npm
install -g npm@11.5.1 or a caret range such as npm install -g npm@^11.5.1) so CI
is reproducible while still meeting the npm >= 11.5.1 requirement; keep the rest
of the step (shell: bash and the version echo) intact.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 70906a49-6fdc-4906-aad1-019e09d24e6c

📥 Commits

Reviewing files that changed from the base of the PR and between 6a806c0 and 5873c74.

📒 Files selected for processing (1)
  • .github/blocks/publish-npm/action.yaml
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Agent
  • GitHub Check: check-skills / check-skills
  • GitHub Check: check-readme / check-readme

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@yanxue06
Yan Xue (yanxue06) merged commit 867b55c into main May 22, 2026
6 of 7 checks passed
@yanxue06
Yan Xue (yanxue06) deleted the ci/npm-oidc-requires-npm11 branch May 22, 2026 05:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants