Skip to content

publish package

Terminal window
holocron publish package [--tag <tag>] [--otp <code>] [--provenance] [--skip-already-published] [--group <folder> | --exclude-group <folder>...] [--package <name or folder>...] [--dry-run]
holocron publish package --initial [--tag <tag>] [--otp <code>] [--dry-run]
holocron publish package --sync-trust <old-file> <new-file> [--repo <owner/repo>] [--force] [--dry-run]

Three modes:

  • Steady-state (no flags, or --provenance/--skip-already-published) — the exec.publishCmd a release.config.ts should call. Runs under CI, authenticated via OIDC automatically — no interactive step. Replaces each repo’s hand-typed pnpm -r --filter=./packages/* publish ... shell with one uniform invocation (config-resolution workstream, #676).
  • --initial — one-shot bootstrap publish for packages that haven’t been registered on npm yet. Solves the chicken-and-egg problem: npm Trusted Publishing (OIDC) requires the package to exist before you can configure it, so the first publish must happen with browser auth.
  • --sync-trust — bulk-migrate npm Trusted Publisher config to a new workflow filename.

--group <folder> limits discovery to the packages in one folder of the repo (clients, observability), for steady-state, --initial and --sync-trust alike. A group with no packages has nothing to publish, so it fails with “nothing to publish” rather than falling back to the root package. --exclude-group <folder> (repeatable) is the opposite: everything except those groups, for the repo-wide release of a repo whose other folders release on their own. See releasing a version group.

--package <name or folder> (repeatable) narrows --initial and --sync-trust to the packages named, so one new package can be bootstrapped or registered without touching the rest: holocron publish package --sync-trust ci.release.yml ci.release.yml --package @theholocron/holocron-plugin-bruno. A name (@theholocron/holocron-plugin-bruno) or a folder (plugins/holocron-plugin-bruno) both work, and it combines with --group. A name that matches nothing leaves nothing to do (“nothing to publish”). A steady-state publish refuses it, because that run releases the whole scope.

A failed package does not stop the rest (--skip-already-published)

Section titled “A failed package does not stop the rest (--skip-already-published)”

With --skip-already-published the command publishes one package at a time (#1387), and one package’s failure costs that package, not the rest of the list:

  • After any failed publish it asks the registry (npm view <name>@<version>). A version that is there counts as published (another run made it).
  • Only npm’s sigstore step answering 409 (TLOG_CREATE_ENTRY_ERROR) is tried again, twice, after 5 s and 15 s, and the registry is checked between tries. Every other failure ends that package at once.
  • Every remaining package is still attempted. The failures are printed together at the end, written to the job summary (GITHUB_STEP_SUMMARY, a table of the packages not published) and the command exits non-zero.

A 409 that survives the retries is not a flake. It means the tarball is byte for byte identical to one already in the transparency log (an earlier publish of the same bytes), so a retry cannot succeed. The report names the package and says so: the fix is a change in the package’s contents and a new release. holocron doctor releases names the tag npm never received for this and the other known cause.

Publishing what is missing for an existing tag

Section titled “Publishing what is missing for an existing tag”

For a version that is already tagged and tried (a failure that is not the identical-tarball case), run the release workflow by hand with the republish_tag input:

Terminal window
gh workflow run ci.release.yml --ref alpha -f group=configs -f republish_tag=configs-v8.9.0-alpha.3 -f dry_run=false
  • group names the tag’s group; for the repo-wide tag (v5.0.0-alpha.254) choose ungrouped. all with a tag is refused, because one tag belongs to one release.
  • dry_run defaults to true for a manual run: the job runs publish package --dry-run and prints what it would publish. Set it to false to publish.
  • The run skips semantic-release: it never makes a tag, a release or a release commit, and holds no write token. It checks out the tag, refuses one that is not on main or alpha, builds, and runs publish package --skip-already-published --tag <channel> (the channel is the tag’s prerelease identifier, latest for a stable version) for that group, or for everything outside the groups for a v<version> tag.
  • It runs from ci.release.yml, the filename the Trusted Publisher entries name, so OIDC publishing works. It cannot start from a push: the input is read only for a workflow_dispatch.
  • The failure table goes to the job summary as in a release run. A tag-only group (ci) publishes nothing, so there is nothing to republish for it.

The same effect locally, with an npm session and --otp:

Terminal window
git checkout configs-v8.9.0-alpha.3 && pnpm install --frozen-lockfile && pnpm build
pnpm exec holocron publish package --group configs --skip-already-published --tag alpha --otp <code>

The generated caller has the input when the release task sets republish: true in its with: (this repo does). It needs the reusable release.yml that has the republish-tag input, so a repo that calls the frozen copies in theholocron/.github does not set it.

Migrating Trusted Publisher config (--sync-trust)

Section titled “Migrating Trusted Publisher config (--sync-trust)”

npm’s Trusted Publisher config is tied to a specific workflow filename per package, and npm checks the calling workflow’s filename. When a workflow calls a reusable one (workflow_call), register the caller, not the reusable: in this repo that is ci.release.yml, which calls the reusable release.yml. Registering the reusable’s name makes the publish fail with ENEEDAUTH. Renaming the release workflow (e.g. release.yml → delivery.publish.yml) breaks OIDC publish (ENEEDAUTH) for every package still registered under the old filename until each one is updated to match.

Terminal window
holocron publish package --sync-trust release.yml delivery.publish.yml

For every public package (auto-discovered the same way as --initial), the command reads the current binding with npm trust list <pkg> --json, which reports the bound file and repository. A package is skipped only when both match the target: the new filename and --repo (default theholocron/holocron, compared case-insensitively). Otherwise the existing binding is revoked and a new one is created:

Current binding Action
same file, same repository skipped
same file, different repository revoked and recreated
different file revoked and recreated
none created

The same-file, different-repository case is what happens when a package is folded into this repo from another one: the workflow filename can stay the same, but npm still trusts the old repo. A binding that reports no repository can’t be proven to match, so it is re-registered too. If the read itself fails for any reason other than a 2FA request (for example E401 when not logged in), that package is reported as errored and nothing is revoked or created for it. Already-migrated packages are skipped, so it’s safe to re-run.

After --initial publishes a new package, the same command registers its Trusted Publisher instead of the npm website: pass the same filename twice (--sync-trust ci.release.yml ci.release.yml). --initial prints this command in its next steps.

npm expires a Trusted Publisher entry that is not used for a publish soon after it is made, and the expired entry still lists the right file and repository. A plain run reads it as matching and skips it, so the next publish keeps failing with ENEEDAUTH. --force revokes and recreates the entry of every package even when it matches:

Terminal window
holocron publish package --sync-trust ci.release.yml ci.release.yml --group configs --force

Run it only when a release is ready to go, and publish right after: a fresh entry that sits unused expires again. With --force a re-run after a 2FA stop redoes the packages it already finished, because a finished entry looks the same as an expired one.

Terminal window
holocron publish package --sync-trust delivery.publish.yml delivery.publish.yml --repo theholocron/holocron --dry-run

--dry-run does the read-only trust list for each package and prints what the real run would do, without revoking or creating anything:

=== @theholocron/env-utils ===
would revoke (repo=theholocron/utils, file=delivery.publish.yml, id=56d3…) and create theholocron/holocron / delivery.publish.yml
=== @theholocron/skills ===
already on theholocron/holocron / delivery.publish.yml, skipping

Reads can need a fresh 2FA approval too. When one does, the dry run stops and prints the authUrl exactly as the real run does; approve it and re-run.

This can’t run unattended. npm’s trust mutations — and reads, once a short-lived OTP grant lapses — require a fresh interactive browser 2FA approval. There’s no token that bypasses this (npm’s own docs: Granular Access Tokens with the bypass-2FA option are explicitly unsupported for trust endpoints). When the command hits this, it stops immediately, prints the authUrl to open and approve, and returns a needs-auth result for that package — open the link, approve it, and re-run.

See issue #689 for the full background.

Terminal window
# Steady-state — the exec.publishCmd release.config.ts calls in CI.
pnpm exec holocron publish package
# Skip packages whose exact version already exists on npm — for repos
# with many independently-versioned packages where a release doesn't
# bump every one (configs' own case).
pnpm exec holocron publish package --skip-already-published
Terminal window
# 1. Build everything
pnpm install --frozen-lockfile && pnpm build
# 2. Bootstrap publish — logs in via `npm login --auth-type=web` automatically
# if `npm whoami` shows no session, then publishes and prints Trusted
# Publisher config links.
holocron publish package --initial --otp 123456

After --initial runs, visit each package’s npm page → Settings → Trusted Publishers to complete the setup (see Self-hosting). The printout names the workflow to register, the release caller found in .github/workflows (ci.release.yml, or delivery.publish.yml in a repo that still has that one).

  • Monorepo (pnpm-workspace.yaml declares public packages): publishes every public workspace package via pnpm -r --filter=./<glob> for each workspace glob (or, with --skip-already-published, one workspace at a time via pnpm --filter <dir> publish).
  • Single package (no workspace packages — most node-template scaffolds): publishes the root package directly via a plain pnpm publish.

The command fails loudly — nothing to publish — rather than silently no-op’ing when it finds no publishable package in either layout.

Option Default Description
--initial false Runs the one-shot bootstrap publish instead of the steady-state path
--tag alpha (--initial) / latest (steady-state) npm distribution tag
--otp — TOTP code from your authenticator (if 2FA is required for writes)
--provenance true Steady-state only: publish with --provenance
--skip-already-published false Steady-state only: check npm view <pkg>@<version> first, skip a package whose exact version exists
--sync-trust — <old-file> <new-file> — migrate every package’s Trusted Publisher config
--package — Only this package, by name or folder (repeatable; --initial and --sync-trust only)
--repo theholocron/holocron owner/repo for the Trusted Publisher config (--sync-trust only)
--force false Replace entries that already match, which npm may have expired (--sync-trust only)
--dry-run false Print what would happen without making any changes (--sync-trust still does the read-only npm trust list)
  • Packages marked "private": true in their package.json are skipped automatically.
  • Steady-state authenticates via CI’s OIDC token exchange — no npm whoami/login step, no Trusted Publisher next-steps printout (both --initial-only).
  • --initial: if npm whoami shows no authenticated session, the command runs npm login --auth-type=web itself (interactive, browser-based) before continuing. If the command detects NPM_TOKEN in env, it prints a reminder to revoke the token afterward.
  • If the (bulk, non---skip-already-published) publish fails with EOTP, the corrected command with --otp is printed.