Skip to content

publish-package: default publish command doesn't pass --ignore-scripts against the bare package-contents artifact #320

Closed

Description

@Shinrai

Where

.github/actions/npm/jobs/publish-npm/generate-command.mjs and .github/actions/npm/jobs/publish-github-packages/generate-command.mjs both build the default publish command as:

finalCommand = `${tool} --access ${accessLevel}`;

(plus --provenance for public npm). Neither adds --ignore-scripts.

What happens

.github/actions/npm/steps/publish-package/action.yml downloads the package-contents build artifact (the npm pack-expanded output of an earlier build job) and runs the generated command with working-directory: package-contents. That directory has no node_modules and — critically — no package-lock.json (npm never publishes lockfiles, and it isn't in a package's "files" either, so there's nothing to npm ci/npm install against even if you wanted to).

npm publish (and pnpm publish/yarn publish) always fires lifecycle scripts (prepack, prepublishOnly, postpack, …) regardless of whether the target directory is a fresh source checkout or an already-built artifact. For any repo whose prepack (or similar) does real work requiring devDependencies — e.g. a bundler build — that script now runs a second time, in a directory that structurally cannot supply what it needs, and crashes the publish outright.

This is the same class of problem as #250 (prepare crashing on a file excluded from "files"), but it's not fixable per-repo the same way: prepare's fix could wrap the missing file in a try/catch no-op because it had nothing legitimate left to do. A repo with a real bundler build (e.g. tsup producing dist/) has no file to fall back to if dist/ itself is missing or stale — the per-repo workaround has to reach for a heuristic ("is the toolchain even available here") instead of a clean no-op, which is a strong signal the guard belongs upstream, not in every consuming repo's package.json.

Why --ignore-scripts is the correct fix here specifically

The reusable publish workflow already runs build_command explicitly in the build job, before packing. By the time execution reaches the publish job, the artifact is supposed to be treated as immutable, already-verified output — no lifecycle script has any legitimate work left to do, and none of them can succeed anyway (no node_modules, no lockfile). Passing --ignore-scripts on the generated publish command matches that invariant exactly, for every consuming repo, without requiring each one to defensively detect "am I in the bare artifact dir or not."

Repro

CLDMV/vitest-runner's v1.4.0 release: both 📦 Publish to NPM and 📦 Publish to GitHub Packages failed identically with sh: 1: tsup: not found (exit 127) once the repo added a real tsup build behind a "prepack": "npm run build" script. The repo currently works around it locally via a node_modules/.bin/tsup-existence check in its own prepack (see PR #40), but that's a per-repo patch for what looks like a workflow-level gap.

Ask

  • Add --ignore-scripts to the default generated command in both generate-command.mjs files.
  • If a repo passes a custom publish_command/github_packages_publish_command, that's presumably intentional and out of scope for this default — but worth a doc note in docs/conventions/ (wherever the publish flow is documented) calling out that a custom command should probably include it too, given the bare artifact has no node_modules.
  • Once released, CLDMV/vitest-runner#(follow-up TBD) will drop its local workaround.

Activity

  1. added theissue type on Sep 27, 2026
  2. added
    type: bug
    priority: high
    status: confirmed
    type: ci
    area: core
    status: in progress
    and removed
    status: confirmed
    on Sep 27, 2026
  3. Shinrai commented on Sep 28, 2026

    @Shinrai
    ContributorAuthor

    Fix is up in #321 (c4dc1aa). The default publish command now passes --ignore-scripts for both npm and GitHub Packages, with any package manager.

    The issue names the two generate-command.mjs files, but those are only fallbacks. The command the reusable workflow actually runs, for the core package and every satellite, comes from github/utilities/repo-detection/action.mjs, a third copy of the same builder. All three now call one shared buildPublishCommand() in npm/utilities/publish-command/ (with unit tests), so the flag can't drift between them.

    Checked against an npm-pack'd artifact whose prepack calls a missing binary. Without the flag, npm publish --dry-run exits 127 (not found, the same failure as vitest-runner v1.4.0) and pnpm fails the same way. With the flag, both publish cleanly. yarn v1 and pnpm both accept --ignore-scripts on publish.

    A custom publish_command / github_packages_publish_command is still used as-is. The caveat about adding --ignore-scripts yourself is now in docs/conventions/package-manager.md → "Publishing from the build artifact". Once this is released, vitest-runner can drop its local prepack guard.

  4. cldmv-bot commented on Sep 28, 2026

    @cldmv-bot
    Contributor

    Closed in v4.29.1 — resolved by #321.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: corepriority: highstatus: in progresstype: bugtype: ci

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions