Skip to content

About

Publishes Node.js projects

Topics

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

🚀 Node.js Package Publish Action

Linux Foundation Source Code License OpenSSF Scorecard

Stamps a version into package.json and publishes the package to an npm registry, such as a Linux Foundation Nexus instance.

node-publish-action

The action wraps the production-proven Linux Foundation publish flow:

npm version <X> --no-git-tag-version && npm publish

It composes node-create-npmrc-action for registry authentication, keeping publish run: logic out of calling workflows. Versions get stamped at publish time, matching the merge-driven release model where committed metadata (such as version.properties), not the committed package.json, provides the version.

Usage Example

steps:
  - name: "Publish npm package"
    id: publish
    uses: lfreleng-actions/node-publish-action@main
    with:
      publish_version: '1.2.3-SNAPSHOT'
      registry_url: 'https://nexus3.example.org/repository/npm.snapshot/'
      load_credential: 'true'
      vault_mapping_json: ${{ secrets.VAULT_MAPPING_JSON }}
      op_service_account_token: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}

Requirements

The action needs no tools on the runner beyond bash and what actions/setup-node installs: every check and every npm invocation runs in its own bundled programs on the selected Node.js. It installs Node.js and npm via the pinned actions/setup-node action, without dependency caching. Real publishes need egress to the target registry; dry-run mode publishes nothing and writes no credential.

The action needs npm 8 or later, the npm that node_version selects, and fails with a clear error on anything older. It resolves the publish registry with that npm's own configuration code, and npm 8 is the oldest release whose behaviour the parity tests verify against npm publish --dry-run: npm 7's dry run never reports its destination, and npm 7 ignores a configured scope where later releases honour it. Node.js 16 was the first LTS line to ship npm 8, and no LTS release shipped npm 7: it came with Node 15 and the pre-LTS Node 16 releases and nothing else. Node.js 14 and older LTS lines carry npm 6. Registry precedence also changed in npm 10.5.2; see Effective Registry for what differs below it. OIDC trusted publishing needs more: npm 11.5.2 and Node.js 22.14.0; see OIDC trusted publishing.

Inputs

Name Required Default Description
publish_version True Version to stamp and publish, such as 1.2.3 or 1.2.3-SNAPSHOT
registry_url False '' Target npm registry URL ending with /; required unless dry_run is 'true'
dry_run False false Pack and verify without publishing (npm may still read the registry); skips credential setup
path_prefix False . Project directory; must resolve within the workspace
tarball_path False '' Publish this already-packed .tgz instead of packing path_prefix; skips the version stamp
if_exists False fail fail, or skip-if-identical to succeed without re-uploading identical bytes; see below
node_version False 22 Node.js version to set up, such as 22, 22.x or lts/*
node_version_file False '' File containing the Node.js version, such as .nvmrc; overrides node_version
tag False latest npm distribution tag
access False '' Package access: public, restricted or unset
provenance False false Generate registry-native provenance (Basic/token auth); needs registry and OIDC support
nexus_user False '' Basic auth username (default: calling repository name); ignored by token and OIDC auth
nexus_password False '' Registry password for Basic auth; required for real publishes unless another mode
auth_token False '' Bearer token written as _authToken; for registries rejecting Basic auth
oidc False false Publish through npm OIDC trusted publishing; stores no credential
load_credential False false Fetch the password from 1Password via credential-load-action
vault_mapping_json False '' JSON mapping repository owner to 1Password vault (with load_credential)
op_service_account_token False '' 1Password service account token (with load_credential)
scope False '' npm scope for the auth entry (for example @onap)

Input Character Allowlists

The action checks free-text inputs against strict whole-string character allowlists before use, rejecting shell metacharacters and embedded newlines:

Input Allowed Structure
publish_version 0-9 A-Za-z . - All-digit MAJOR.MINOR.PATCH segments plus an optional -suffix
registry_url A-Za-z 0-9 . : / _ - https:// scheme, non-empty host, trailing /, no userinfo
tag A-Za-z 0-9 . _ - Non-empty
node_version A-Za-z 0-9 . * / _ - Follows setup-node version syntax

The nexus_user, scope and credential inputs pass through to node-create-npmrc-action, which applies its own validation.

Outputs

Name Description
published_version Published version; stamped into package.json unless tarball_path supplied it
package_name Package name from the publish metadata
tarball_name Tarball filename from the publish metadata
published true if uploaded, already-present if skipped as identical, else false
integrity The package's sha512-<base64> integrity, from npm or the registry

Behaviour

  1. Set up Node.js: actions/setup-node installs the version node_version or node_version_file selects. Everything after it runs on that Node.js and its npm, including the action's own checks
  2. Check inputs and resolve the registry: tests every input against its allowlist; real publishes need registry_url and a credential source as well, failing fast with a clear error otherwise. With load_credential: 'true', real publishes need non-empty vault_mapping_json and op_service_account_token values too. Then works out where npm will actually publish, which a scoped package can redirect away from registry_url. See Effective Registry. This runs before authentication because the next step replaces the project's .npmrc, one of the files resolution reads
  3. Authenticate (real Basic or token publishes): node-create-npmrc-action writes an authenticated .npmrc into the project directory, keyed to the resolved registry. Trusted publishing writes nothing; the checking step has instead confirmed the toolchain, the token endpoint, and that no stored credential could stand in for the exchange
  4. Stamp: npm version <X> --no-git-tag-version --allow-same-version --ignore-scripts --no-workspaces updates package.json, with the result read back and verified. A ::notice:: names any preversion/version/postversion scripts the project defines, since --ignore-scripts means they do not run. Skipped entirely with tarball_path, where the archive already carries the version
  5. Publish: npm publish --json --no-workspaces with the configured tag, access and provenance flags, packing the project directory — or npm publish <tarball> when tarball_path names an archive, which packs nothing. It also pins the user and global configuration files resolved in step 2, since a project .npmrc can select them and step 3 replaces it. The action then recovers npm's metadata from the captured output and checks the published version against the request. See Publish Output Parsing
  6. Verify (real publishes): npm view <name>@<version> against the target registry confirms availability; an unreadable package downgrades to a warning (registries may restrict anonymous reads or index asynchronously), while a readable package with the wrong version fails the action

Steps 4 to 6 run as one program. The checking step records every decision in a state file in a private directory under RUNNER_TEMP, outside the checked-out tree, and the publish reads that file alone, checked against one schema. It runs npm as the same npm whose code resolved the registry, refusing to publish if PATH now names a different one, and re-checks the project directory before stamping and again before verifying, since lifecycle scripts run between them. An always() step removes the directory at the end.

Publish Output Parsing

npm runs lifecycle scripts with inherited stdio, so whatever prepublishOnly, publish and postpublish print lands in the same stream as npm's --json output. That stream seldom holds a bare JSON document, and it can contain unbalanced braces or JSON objects the hooks produced themselves.

The action locates npm's object structurally, restarting at every opening brace so an unbalanced one cannot swallow the rest, and then selects by shape: an object counts as publish metadata when it carries name, version and filename as strings, in either npm generation's layout. npm 10 placed those at the top level; npm 11 keys the object by package name.

npm's report also carries the archive's sha512 integrity, which the action passes on as the integrity output. Copies of the same report that disagree on it describe different archives, as when a prepublishOnly script prints npm pack --json for an earlier one. The action then reports no digest, and fails as for unreadable metadata rather than describe bytes that were not uploaded. npm 11's keyed report stands over a flat copy that disagrees with it.

If npm's exit status is non-zero, the action reports a publish failure — unless npm's output already reports the requested version as published. npm prints that report once the registry has accepted the upload and not before, and from npm 10 before the publish and postpublish scripts run, so a failing script can follow a completed publish. The action then says the package has probably reached the registry and to check it before retrying. npm 8 and 9 print the report after those scripts instead, so a failure there leaves no report at all; when the package defines publish or postpublish, the action says the same of any failure. Output too large to read whole likewise leaves the outcome unknown.

If npm succeeded and the action still cannot read the metadata, it says so explicitly and states that the package reached the registry, because retrying that publish cannot succeed — it fails with EPUBLISHCONFLICT on a version that the registry already holds. The same applies when verification reads back a different version.

Note

The action tolerates hooks that print to stdout, but stdout is the channel npm reports through. A hook printing an object carrying name, version and filename as strings looks like npm's own report in every respect but the version, so prefer stderr for hook diagnostics.

Dry-Run Mode

With dry_run: 'true' the action runs npm publish --dry-run, which packs the package and reports the metadata without publishing. npm may still consult the registry while doing so. Dry-run mode skips the .npmrc/credential steps entirely, so it needs no registry_url and no credential inputs.

The input alone decides. Otherwise the action passes --no-dry-run, and a dry-run setting in an .npmrc or npm_config_dry_run cannot turn a real publish into a rehearsal after the action has set it up as a real one.

CI holds no registry credentials and completes no publish, so the testing workflow uses dry-run mode wherever the path under test allows it. One case cannot: the token pass-through test inspects the generated .npmrc, which dry-run mode never writes, and then fails against a registry host that does not exist.

Authentication Modes

Three mutually exclusive modes. Supplying more than one fails the action rather than picking a winner, since the effective credential would otherwise be ambiguous.

Mode Inputs Stored credential
Basic auth nexus_password, or load_credential .npmrc _auth
Bearer token auth_token .npmrc _authToken
Trusted publishing oidc: 'true' None

Basic auth (Nexus)

Pass nexus_password directly, or set load_credential: 'true' with vault_mapping_json and op_service_account_token to fetch it from 1Password. node-create-npmrc-action writes an _auth entry holding base64(username:password).

Bearer token

Pass auth_token. Written as an _authToken entry. Registries that reject Basic auth for publishing, notably registry.npmjs.org, require this form.

nexus_user plays no part in token publishing, since a bearer token carries no username. Setting it alongside auth_token (or oidc) is inert rather than an error — callers that compute it unconditionally, such as a matrix publishing to both Nexus and npmjs.org, would otherwise have to strip it per target. The action emits a ::notice:: naming it as ignored.

OIDC trusted publishing

Set oidc: 'true'. Nothing stores a secret: at publish time npm exchanges the job's GitHub OIDC token for a short-lived publish token, scoped to the one package. The action writes no .npmrc.

jobs:
  publish:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      id-token: write  # mandatory for trusted publishing
    steps:
      - uses: actions/checkout@<sha>
        with:
          persist-credentials: false
      - uses: lfreleng-actions/node-publish-action@<sha>
        with:
          publish_version: '1.2.3'
          registry_url: 'https://registry.npmjs.org/'
          node_version: '24'
          oidc: 'true'

Set up the trusted publisher first. On npmjs.com, open the package's settings and add a GitHub Actions trusted publisher naming the organisation or user, the repository, and the workflow filename (see the npm documentation on trusted publishers). A package must exist before it can have a trusted publisher, so a brand-new package needs its first version published another way.

Important

Reusable workflows. When this action runs inside a reusable workflow called with workflow_call, npm checks the filename of the calling workflow, not the reusable one. Register the caller's file (release.yaml in your repository, say), and grant id-token: write on both the calling job and the called workflow's job; GitHub issues no token unless both allow it.

Further requirements, each checked up front with a remedy:

  • npm 11.5.2 or later and Node.js 22.14.0 or later, as selected by node_version. Node 22 ships npm 10, and even Node 24.0.0 ships npm 11.3.0, so pick a current Node 24 release. The floor excludes 11.5.1: it auto-enables provenance before checking visibility, so a restricted publish fails outright (npm/cli#8467). The action runs actions/setup-node itself, so upgrading npm under a different Node installation beforehand has no effect. The action holds dry runs to the same floor, since a rehearsal on a toolchain the real publish rejects proves nothing.
  • id-token: write on the job. Without it the action fails before stamping anything, naming the grant.
  • No stored credential for the registry. npm's exchange is best effort: if it fails, npm falls back to any credential it can find, which would publish under a long-lived token while the caller believes none exists. The action refuses to proceed when one exists. It asks npm's own getCredentialsByURI, on the registry npm will actually publish to, so .npmrc files at every level and npm_config_* variables count as npm counts them.
  • GitHub-hosted runners, and a repository.url in package.json matching the GitHub repository. npm enforces both; the action cannot check them in advance.

Mode isolation

npm attempts a trusted-publish exchange whenever the job's OIDC token endpoint is available. A Basic or token publish in a job that grants id-token: write for some other step, such as attestation, could have its credential replaced without any sign. The action withholds the endpoint from every npm invocation except a real trusted publish, or a real publish with provenance enabled, which signs with the workflow identity. It removes NPM_ID_TOKEN from every invocation, since npm reads it ahead of the endpoint, matching variable names case-insensitively as Windows does.

The provenance case is the one isolation cannot cover. Signing and the exchange read the same endpoint, and npm attempts the exchange whenever the endpoint exists, so a Basic or token publish with provenance authenticates through a trusted publisher if the package has one. The action says so in a notice; use oidc: 'true' to make that the declared mode.

Trusted publishing checks for stored credentials before npm runs, so for a directory publish it cannot bind prepack, prepare or prepublishOnly scripts, which run inside npm and could add a scope or a credential of their own. The action names such scripts in a notice; publish through tarball_path, which runs none, to rule this out.

Workspaces

This action publishes the single package at path_prefix. Both npm version and npm publish are workspace aware, so the action passes --no-workspaces to each: without it, stamping rewrites every sibling manifest and leaves the target at its committed version, and publishing fans out across the whole workspace while the action verifies and reports a single package.

To publish more than one workspace package, call the action once per package with its own path_prefix.

A workspace selected through npm_config_workspace fails the input checks. One selected through a workspace= entry in an .npmrc fails at the stamp instead, before anything reaches the registry: npm exposes such a selection through neither npm config get workspace nor npm config list, so nothing can catch it earlier.

Which .npmrc holds that entry changes when it applies. For real publishes the credential step writes the project .npmrc before the stamp runs, truncating whatever it replaces, so a project-level selector never survives to affect the publish. A selector at any other config level — the user ~/.npmrc, for instance — does survive, and stops the run at the stamp. Dry runs skip the credential step, so a project-level selector reaches the stamp there too.

Credential Handling

node-create-npmrc-action masks the credential material, writes the .npmrc with restrictive permissions and registers a guaranteed post-job step that scrubs the file again — including when later steps fail. This action adds no duplicate cleanup logic. Trusted publishing stores no credential, so there is nothing to scrub.

Provenance

Under trusted publishing npm attaches provenance by itself, for a public package published from a public repository, so the action refuses the provenance input alongside oidc. It refuses an ambient setting too: provenance or provenance-file enabled through an .npmrc, npm_config_provenance or publishConfig. It adds nothing, and npm refuses explicit provenance for a restricted package.

Turning provenance off works, but the sources differ, because npm auto-enables it while the configuration setting holds its default, and not otherwise:

provenance=false set in Trusted publish attests?
.npmrc or npm_config_provenance No
package.json publishConfig alone Yes: npm overrides it

The action emits a notice explaining which applies.

Under Basic or token auth the provenance input passes --provenance to npm, generating registry-native Sigstore provenance. This works against registries with provenance support (npmjs.org) and needs id-token: write. Nexus has no provenance support, so leave the input at false for Nexus targets; generate GitHub artifact attestations for the packed tarball instead.

The action resolves provenance before the .npmrc step replaces the project's .npmrc, from the input and every source npm reads, and passes the result to npm publish as --provenance or --no-provenance, or as --provenance-file when the configuration names a pre-signed bundle. A setting in the project's .npmrc still applies after the replacement, and one it overrode does not come back. The OIDC token endpoint follows whether npm will sign.

Effective Registry

registry_url names where the action asks npm to publish. npm does not always agree, and the action now resolves the difference instead of assuming it away.

npm picks the registry with pickRegistry, which prefers a scoped setting, over its resolved options with the package's publishConfig flattened on top. The search order is:

  1. publishConfig["@scope:registry"], for the package's own scope
  2. @scope:registry from npm configuration (.npmrc)
  3. the same two keys again for the configured scope — publishConfig's scope when the manifest has one, else npm's scope setting — which redirects packages that are not themselves scoped
  4. registry_url

Which publishConfig keys npm applies depends on the npm release:

npm publishConfig keys set on the command line
before 10.5.2 applied anyway, over the flag
10.5.2 and later skipped, so the flag wins

publishConfig.registry behaves differently either side of that line. From npm 10.5.2 it loses to the --registry this action passes, and decides when registry_url is empty. Before 10.5.2 it wins even over registry_url, and the action reports that destination. Node 16's npm, and older patch releases of Node 18 and 20, are below the line.

A publishConfig key that is present but empty still counts: npm flattens it over the resolved options, so it masks any .npmrc value for the same key and the search moves past both.

The action does not reimplement any of this. It loads the publishing npm's own configuration and pickRegistry in-process and asks them; the release-dependent key filtering is the one rule npm keeps inside its publish command rather than an importable module, so the action gates that on the npm version. A parity test runs npm publish --dry-run for 37 scenarios on npm 8, 9, 10.5.1, 10.5.2, 10.9, 11 and 12, and requires the action to name the same destination as npm on each.

With tarball_path, the manifest consulted is the one inside the archive, because that is the one npm reads: a tarball's scope and publishConfig decide its registry, and the working directory's manifest never takes part in the publish.

Before this resolution the publish went to the right place — npm was always correct — but the action reported registry_url in the job summary and ran npm view --registry "${registry_url}" to verify. A redirected publish then either failed verification for no reason, or "verified" against a registry it never reached, which is a false confirmation where the name exists in both.

The resolved value now drives the publish, the summary line and the verification alike — and the publish and verification commands pin it under every consulted scope as well as --registry. npm re-reads the manifest after prepublishOnly runs, so a script adding the scoped publishConfig key could otherwise redirect the publish once resolution had finished. Pinning the winning scope and nothing else would leave a gap, because pickRegistry checks the package's own scope first and npm view does not load publishConfig at all.

The pins close that window from npm 10.5.2 onward. They work by being command-line keys, which npm skips in publishConfig from that release on. Before it, npm applies a publishConfig key over the flag, so a lifecycle script can still redirect the publish past a pin. Publish through tarball_path to rule it out on any npm: npm runs no lifecycle scripts for a tarball.

The action refuses a scope whose pin would name the wrong key, rather than leave it unpinned. A line break would split the one-per-line scope list, and npm splits a command-line flag at its first =, so a pin for @a=b would name the key @a.

The pinned value is the one resolved from the project's own files, so this fixes the destination rather than overriding the project's intent.

One case a pin cannot cover: a lifecycle script that introduces a new scope. prepack, prepare and prepublishOnly run inside npm publish, and npm re-reads the manifest afterwards, so renaming @old/pkg to @new/pkg — or setting publishConfig.scope beside a matching @new:registry key — can select a registry no pin could have named in advance.

Nothing can catch this after the fact either. postpublish may restore a name prepublishOnly changed, or change one itself, and npm's own JSON reports the manifest it read before the hooks. So a directory publish defining any of those scripts gets a notice saying the risk exists, rather than a check that would be wrong in both directions.

Publishing through tarball_path removes the possibility entirely: npm runs no lifecycle scripts for a tarball, so the manifest cannot change underneath the resolution.

When the resolved value differs from registry_url the action emits a notice naming the source, so an override is visible rather than silent:

::notice::Publishing to https://registry.npmjs.org/, not the
registry_url https://nexus3.example.org/repository/npm.release/.
The project selects it through publishConfig-scoped.

An override gets the same scheme check as registry_url, which it had never had: it arrives from the project's own files, and under trusted publishing npm sends a token to whatever registry wins. A non-https override fails the action rather than redirecting the publish.

The configuration half of the answer is npm's own: the action loads the publishing npm's @npmcli/config in-process, from that npm's own installation, rather than parsing .npmrc or decoding npm config get output. The manifest supplies publishConfig, because npm's configuration does not load it at all — which is why this redirection was invisible.

Publishing a Pre-Packed Tarball

By default the action packs path_prefix at publish time. Set tarball_path to publish an archive that already exists instead:

- uses: lfreleng-actions/node-publish-action@<sha>
  with:
    publish_version: '1.2.3'
    tarball_path: 'pack-dist/my-package-1.2.3.tgz'
    registry_url: 'https://registry.example.org/'

This matters when something else has to reason about the exact bytes that reach the registry. npm pack and npm publish each build their own archive, and the two can differ: npm runs prepublishOnly for publish and not for pack, so a project generating content in that hook ships files a separately packed tarball never contained. Handing npm the packed archive removes the second pack, which makes an attestation over that archive describe what actually published.

Three consequences follow from the tarball being the artefact:

  • The action skips the version stamp. The archive already carries its version, and rewriting the working tree would change a manifest nothing reads. The action instead reads the version out of the tarball, with the publishing npm's own manifest reader, and requires it to equal publish_version, so a stale archive cannot publish under a version the caller never asked for. Because the reader is npm's, the version compared is the one npm sends: a v1.2.3 in the archive publishes as 1.2.3, and matches that request. The action copies the archive into RUNNER_TEMP before reading it, validates the copy, and the publish uses that copy; a final always() step removes it. No check around a read of the workspace path could be atomic with that read, so the action moves the bytes outside the checked-out tree first — the version, identity and registry the publish relies on come from the file it publishes.
  • npm runs no lifecycle scripts. It gates prepack, prepare, prepublishOnly, publish and postpublish on packing a directory. Removing the second pack is the point, and losing prepublishOnly is how the two archives stop diverging — but a project relying on postpublish needs another home for that work.
  • path_prefix still matters. npm resolves configuration and credentials from the working directory, so it keeps pointing at the project.

tarball_path follows the same rules as path_prefix: relative values resolve against GITHUB_WORKSPACE, and the resolved path must stay inside it. The action resolves the path before it inspects the file, so a symlink counts as its target rather than its own location.

Re-running a Publish

npm-compatible registries never overwrite a version: publishing one that exists fails with EPUBLISHCONFLICT. A publish to more than one registry is not atomic either, so re-running one that partly succeeded fails on every registry that already holds the version.

if_exists: 'skip-if-identical' makes that re-run safe. Before uploading, the action asks the registry for the version's dist.integrity, using the resolved registry and every consulted scope pinned, as for the publish itself:

Registry holds the version Result
No Publishes as usual; published is true
Yes, with the same sha512 integrity Succeeds without uploading; published is already-present
Yes, with different content Fails, naming both integrities
Cannot tell (any error but E404, or no sha512 reported) Fails rather than publish blind

Identity is a comparison of bytes, so this needs tarball_path. The action hashes the staged copy of the archive, the exact bytes npm would upload. A directory publish has no archive to compare until npm packs it inside the publish. Dry runs upload nothing, so they never ask.

The check reads the registry with the publish's own credentials. Under OIDC trusted publishing there is no stored credential, so for a restricted package the registry answers E404 either way. The action then publishes as it would without this input, and if the version is there, npm's own EPUBLISHCONFLICT stops it.

Path Constraints

Relative values for path_prefix resolve against GITHUB_WORKSPACE, not the current working directory, so behaviour stays deterministic when a calling workflow sets a custom working directory. The project directory must resolve within GITHUB_WORKSPACE and contain a package.json. The publish re-checks that it still resolves to the same place before stamping and again before verifying. Paths that escape the workspace fail the action.

Notes

  • The action performs no dependency caching, in line with the organisation's cache-poisoning stance. That includes the npm cache actions/setup-node enables by itself when the repository's root package.json names npm in packageManager or devEngines.packageManager: the action passes package-manager-cache: false. Without that, a root with no lockfile would also fail at setup-node, which cannot find one to key the cache on
  • --allow-same-version keeps re-stamping idempotent when the committed package.json version already matches the request
  • Stamping uses --ignore-scripts, so preversion, version and postversion do not run. No release lane installs dependencies before stamping, so a hook invoking the test or build script could not succeed; suppressing them keeps the merge-driven and tag-driven lanes producing the same tree. The action emits a ::notice:: naming the skipped scripts, because a dependency-free version hook (writing the version into a source constant, say) would otherwise go missing from the published package with no signal
  • Publishing a directory runs prepublishOnly/prepack/prepare scripts when the project defines them; run builds beforehand (for example via node-build-action) so the packed content is complete
  • Publishing a tarball runs no lifecycle scripts at all. npm gates prepack, prepare, prepublishOnly, publish and postpublish on packing a directory, so a project relying on any of them — a postpublish notification, say — needs another home for that work under tarball_path

Development

The action remains a composite action, so it can call actions/setup-node to select the Node.js version the publish runs under. Every step after that runs one of two bundled TypeScript programs: dist/prepare checks the inputs and resolves the registry, and dist/publish stamps, publishes and verifies. Their logic lives under src/ as functions with unit tests.

npm ci          # install the toolchain
npm run typecheck
npm test        # vitest
npm run build   # bundle src/ into dist/ with esbuild

esbuild strips the TypeScript types itself, so bundling stays independent of the compiler version; tsc --noEmit handles type checking. The build output is deterministic, which the bundle check depends on.

TypeScript 7 ships no compiler API, which typescript-eslint needs, so the two versions run side by side as the TypeScript 7 release notes describe. @typescript/native aliases TypeScript 7 and provides tsc; typescript aliases @typescript/typescript6 for ESLint. Keep that pairing when upgrading either one.

knip.jsonc configures Knip, which the aislop scan runs to find unused files, exports and dependencies; run it with npx knip. Knip cannot see the bundle entry points through action.yaml, so the file names src/bin/*.ts and the tests directly. The scan runs without node_modules, so the file also disables the Vitest plugin, which would load vitest.config.ts, and lists the tools that package.json scripts and hooks run. Add any new entry point there.

Two different Node.js floors apply, and they are not the same number:

  • The development toolchain needs the version in engines (^20.19.0 || ^22.13.0 || >=24), the range ESLint, vitest and vite all support. It governs npm ci and the commands above
  • The bundles target node18, because they run on whatever node_version selected for the publish rather than on the toolchain. Each step runs its bundle with --selftest first, so a runtime too old to load it fails the run while nothing has yet reached the registry

The repository commits dist/. GitHub runs an action straight from the repository and offers no build step, so the bundle has to be present. The Bundle / Committed bundle matches sources 📦 CI check, from the node-workflows bundle-check.yaml reusable workflow, rebuilds it and fails when the result differs from what the repository holds, which keeps it in step with src/. Run npm run build and commit the result alongside any source change. On a Dependabot pull request the same workflow commits the rebuilt bundle to the branch itself, through the organisation's GitHub App.

The bundle carries no third-party runtime dependencies. src/actions-io.ts implements the slice of the Actions runner protocol this action needs — outputs, workflow commands and their escaping — with unit tests, which keeps the committed bundle small enough to review.

The npm test fixtures and Dependabot

test/npm-versions/ holds one npm per supported major (npm-6 to npm-12), plus the releases either side of the 10.5.2 publishConfig change (boundary-10.5.1, boundary-10.5.2). Each directory pins one npm release in a package.json and lockfile, and CI installs them side by side for the loader and parity tests. They are test subjects, not dependencies of the action.

GitHub reads each lockfile as a real manifest, though. The packages npm bundles raise Dependabot alerts, and Dependabot security updates try to fix them. For npm, a security update moves the parent package when nothing else clears the advisory, and for a package npm bundles that parent is npm itself: security updates proposed moving five fixtures to npm 12. .github/dependabot.yml cannot stop this. Its ignore rules apply to version updates alone, and directories it leaves out still receive security updates.

Three safeguards keep each fixture in place:

  • A repository Dependabot auto-triage rule dismisses every alert on the fixture lockfiles, indefinitely. Dependabot raises security updates for open alerts alone, so it raises none for the fixtures. Version updates within each major still arrive, as .github/dependabot.yml configures them
  • Tests fail any change that moves a fixture. test/npm-versions.test.ts pins each npm-<N> to major N, and test/publish-options.test.ts pins the boundary fixtures to their exact releases
  • Each fixture directory carries an osv-scanner.toml that skips every package in it. The OpenSSF Scorecard Vulnerabilities check scans with OSV-Scanner, which reads neither Dependabot's dismissals nor its rules, and would otherwise report each advisory against the pinned npm releases. The file covers its own directory alone, and test/npm-versions.test.ts requires one in every fixture

The rule lives in the repository settings, under Settings → Advanced Security → Dependabot rules, not in the repository itself. Its manifest filter takes no wildcards, so it names each lockfile. Give each lockfile its own manifest: term. The rule holds these nine, entered on one line and separated by spaces:

manifest:test/npm-versions/npm-6/package-lock.json
manifest:test/npm-versions/npm-7/package-lock.json
manifest:test/npm-versions/npm-8/package-lock.json
manifest:test/npm-versions/npm-9/package-lock.json
manifest:test/npm-versions/npm-10/package-lock.json
manifest:test/npm-versions/npm-11/package-lock.json
manifest:test/npm-versions/npm-12/package-lock.json
manifest:test/npm-versions/boundary-10.5.1/package-lock.json
manifest:test/npm-versions/boundary-10.5.2/package-lock.json

The form also accepts a comma-separated list, but stores it as one value that matches no alert, and the settings page shows both forms the same way. The organisation audit log records what the form stored: a vulnerability_alert_rule.create or .update event lists the manifest condition, which must hold one entry per lockfile.

Adding or renaming a fixture directory means three changes: add its lockfile to the rule, give it an osv-scanner.toml, and, for an npm-<N> directory, check that it falls inside the directories glob in .github/dependabot.yml.

The repository Dependabot rule for the npm test fixtures

About

Publishes Node.js projects

Topics

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages