Repository navigation
fix(ci): publish CLI via npm stage like plugins #3152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,16 +64,40 @@ jobs: | |
| CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | ||
| FROM_TAG: ${{ steps.changelog_base.outputs.from_tag }} | ||
| run: bun run changelog:ai | ||
| - name: Publish CLI to npm | ||
| - name: Setup Node.js for npm publish | ||
| uses: actions/setup-node@v6 | ||
| with: | ||
| node-version: 24.x | ||
| registry-url: 'https://registry.npmjs.org' | ||
| - name: Install npm CLI for staged publishing | ||
| run: npm install -g npm@^11.15.0 | ||
| - name: Stage publish to npm | ||
| if: ${{ !contains(github.ref, '-alpha.') }} | ||
| working-directory: cli | ||
| env: | ||
| NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
| run: bun publish --cwd cli --access public | ||
| - name: Publish CLI to npm with next tag | ||
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
| run: | | ||
| npm --version | ||
| npm stage publish --tag latest --provenance --access public --ignore-scripts | ||
| - name: Stage publish to npm with next tag | ||
| if: ${{ contains(github.ref, '-alpha.') }} | ||
| working-directory: cli | ||
| env: | ||
| NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
| run: bun publish --cwd cli --tag next --access public | ||
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
| run: | | ||
| npm --version | ||
| npm stage publish --tag next --provenance --access public --ignore-scripts | ||
|
Comment on lines
+74
to
+89
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift 🧩 Analysis chain🌐 Web query:
💡 Result: In npm CLI v11, the Citations:
🏁 Script executed: #!/bin/bash
set -e
printf '%s\n' '--- workflow ---'
sed -n '1,140p' .github/workflows/publish_cli.yml
printf '%s\n' '--- CLI package metadata ---'
sed -n '1,180p' cli/package.json
printf '%s\n' '--- related stage/release references ---'
rg -n -C 3 'npm stage|npm-stage-approve|create release|github release|gh release|version' .github cli/package.jsonRepository: Cap-go/capgo.app Length of output: 50372 🌐 Web query:
💡 Result: The npm stage command is part of a workflow designed to facilitate secure package publishing in automated environments [1]. It allows maintainers to stage a package version to the registry without needing to provide 2FA at the time of staging, deferring that requirement to a later approval step [1]. Key commands within the npm stage workflow include: - npm stage publish []: Packages the current working directory and places it into the registry in a non-public state [1]. This command does not require 2FA, making it suitable for automated CI/CD workflows [1]. - npm stage list []: Lists all currently staged package versions [1]. - npm stage approve : Publishes a previously staged package version to the registry [1]. This command requires 2FA to complete the publication [1]. Other available commands for managing staged packages include npm stage view (to view details), npm stage reject (to remove a staged package, requiring 2FA), and npm stage download (to download a tarball for inspection) [1]. This workflow ensures that automated processes can prepare a release while human maintainers retain the final, secure control over public publication [1]. Citations: 🌐 Web query:
💡 Result: The npm stage command is part of the staged publishing workflow introduced in npm CLI, which allows developers to stage a package version for later review and approval, often to facilitate automated CI/CD processes without requiring 2FA during the initial publish step [1][2]. To list staged packages, you use the command: npm stage list This command lists all currently staged package versions [1][2]. While the command itself lists the available staged items, interaction with specific packages—such as approving, rejecting, or downloading them—often requires a unique identifier (a UUID) to ensure you are operating on the correct candidate [3]. If you are looking to find the stage ID for a specific package, you can run npm stage list and identify the correct entry from the output. In scenarios where multiple candidates for the same package version exist, the CLI may require you to use the specific UUID provided by the list command to ensure idempotency and prevent errors [3]. Key commands in the npm stage workflow include: npm stage publish: Stage a package for publishing (no 2FA required). npm stage list: List all staged package versions. npm stage view : View details of a specific staged package. npm stage approve : Approve and publish a staged package (requires 2FA). npm stage reject : Reject and remove a staged package (requires 2FA). npm stage download : Download the staged tarball for inspection. Citations:
Make staged releases recoverable after approval-dispatch failures.
Fail the workflow when dispatch fails. On reruns, reuse the existing stage ID from 📍 Affects 1 file
🤖 Prompt for AI Agents |
||
| - name: Request stage approval | ||
| continue-on-error: true | ||
| working-directory: cli | ||
| env: | ||
| GH_TOKEN: ${{ secrets.NPM_STAGE_DISPATCH_TOKEN }} | ||
| run: | | ||
| gh api --method POST repos/Cap-go/automations/dispatches \ | ||
| -f event_type=npm-stage-approve \ | ||
| -f "client_payload[repository]=${GITHUB_REPOSITORY}" \ | ||
| -f "client_payload[run_id]=${GITHUB_RUN_ID}" \ | ||
| -f "client_payload[package]=$(node -p "require('./package.json').name")" | ||
| - name: Create GitHub release | ||
| id: create_release | ||
| uses: softprops/action-gh-release@v2 | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🌐 Web query:
Does npm CLI version 11.15.0 supportnpm stage publishon Node.js 24?💡 Result:
Yes, npm CLI version 11.15.0 supports the npm stage publish command [1][2]. The npm stage publish feature was officially introduced in npm version 11.15.0 [1][3]. While the documentation for staged publishing specifies that it requires npm CLI version 11.15.0 or later, it also notes that it requires Node.js version 22.14.0 or higher [4]. As Node.js 24 includes npm 11 and is a more recent release than Node.js 22, it meets the underlying Node.js environment requirements to run npm 11.15.0 and its associated features [5].
Citations:
🏁 Script executed:
Repository: Cap-go/capgo.app
Length of output: 9777
🏁 Script executed (no clone):
Length of output: 1261
Pin the npm CLI version.
npm@^11.15.0can select future npm 11 releases in this privileged release job. Install an exact reviewed version and update it through reviewed pull requests.Proposed fix
📝 Committable suggestion
🧰 Tools
🪛 zizmor (1.29.0)
[warning] 73-73: ad-hoc installation of packages (adhoc-packages): installs a package outside of a lockfile
(adhoc-packages)
🤖 Prompt for AI Agents
Source: Linters/SAST tools