Safeguard
Supply Chain•

Should you publish packages from CI or from your laptop?

Publishing from CI with trusted publishing avoids stored tokens, while laptop publishing with 2FA keeps a human in the loop. How to choose for a project.

Safeguard Security Team
4 min read

For most projects, publish from CI using trusted publishing, because no long-lived token exists to steal and the release is tied to a specific workflow. Publish from a laptop only when you need a human prompt on every release, and then require 2FA and disallow tokens.

The two models

Laptop publishing means you run the publish command yourself after a 2FA prompt. CI publishing means a workflow does it when you push a tag, and the registry trusts that workflow through OpenID Connect (OIDC).

npm's own guidance lists the options it intends to leave for publishing: local publishing with required 2FA, granular tokens with a limited lifetime of seven days, and trusted publishing. The GitHub post describes this as a plan with gradual rollout, so check current npm documentation for what applies to your account today.

What each model protects against

ThreatLaptop with 2FACI with trusted publishing
Token leaked from a CI secretNo token neededNo stored token to leak
Malware on a developer machineExposed, since the session and keys live thereLess exposed, publish happens elsewhere
Stolen password aloneBlocked by 2FANot relevant to the CI path
Malicious workflow editNot relevantExposed, so protect the workflow
Release made by mistakeHuman sees promptTag push can trigger it, so add a reviewer gate
Provenance for consumersNot generatedGenerated automatically on supported providers

The last row comes from npm's trusted publishing page, which says provenance is generated automatically for GitHub Actions and GitLab publishes from public repositories of public packages, and not for private repositories.

When laptop publishing still makes sense

  • Your registry does not support trusted publishing for your CI provider.
  • You release rarely and want a deliberate human step.
  • You use a hardware key and a clean, dedicated machine.

When to choose CI

  • You release often.
  • More than one person can release.
  • You want provenance on each version.

If you pick CI, treat the workflow as the crown jewel. Pin actions, set job level permissions, add an environment with required reviewers and use CODEOWNERS. These are covered in the release workflow permissions guide, required reviewers for deployment approval and CODEOWNERS for workflows.

A hybrid that many projects use

Let CI do the publish, but disallow tokens on the package so a leaked token cannot be used from anywhere else. npm's trusted publishing page recommends setting publishing access to require 2FA and disallow tokens, and states this does not affect OIDC publishing. Details are in what disallow tokens does on npm.

Decision steps

  1. Does your registry support trusted publishing for your provider? If no, use laptop with 2FA.
  2. Do you want provenance? If yes, use CI.
  3. Do you have a second person who can review release workflow changes? If no, add a ruleset and consider two person review options.
  4. Remove old tokens either way.

Safeguard can scan the dependencies that go into each release and gate pull requests, and the free scan at gold.safeguard.sh/scan is a fast start.

Quick check

Is CI publishing safe if my repository is compromised?

No. A compromised repository or workflow can publish. That is why workflow protection and reviewer gates matter.

Do I need provenance to use CI?

No, but trusted publishing on supported providers generates it automatically for public packages from public repositories.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.