Skip to content

CLI Reference ​

Installing @neosjs/release registers two equivalent commands: release and neos-release.

Basic Usage ​

bash
release [<increment>] [options]

Positional Argument <increment> (or -i / --increment) ​

You can specify a semantic increment type or an explicit target version:

ValueDescription
patch / minor / majorStable release increment
prepatch / preminor / premajorPre-release increment (case-insensitive, so prePatch is equivalent to prepatch)
prerelease / preContinue the current pre-release series by incrementing the pre-release number
Explicit version (such as 2.0.0, 2.0.0-rc.1)Use the specified version directly (it must be greater than or equal to the current version; non-canonical formats are coerced through semver.coerce with a warning)
--no-incrementDo not increment the version and keep the current latest version (commonly used to backfill a Release, attach assets, or retry a push after a failure)

When <increment> is omitted:

  • Interactive mode: a version selection list is shown, with the version type recommended from commits highlighted and pre-selected (switch with the arrow keys or choose "Custom version").
  • CI mode (--ci): the version type recommended by the changelog plugin from releasable commits takes precedence; if there are new commits since the last tag but no releasable changes (and the default changelog.requireReleasableCommits is enabled), a notice is printed and the release is skipped with exit code 0; when the recommendation is disabled or there are no new commits at all, patch is used by default (prepatch or a continued prerelease in pre-release mode).

All CLI Options ​

General and Debugging Options ​

OptionShorthandDescription
--config <path>-cPath to a local configuration file; pass --no-config to disable loading local configuration files
--dry-run-dDry-run mode: only prints the write commands that would run, without actually modifying files or pushing (see Dry Runs and Troubleshooting)
--increment <val>-iSpecify the increment type or an explicit version; pass --no-increment to skip the version increment
--verbose-VVerbose output: -V prints external command/hook output, -VV prints all commands with detailed logs, -VVV also includes debug logs
--version-vPrint the version information of @neosjs/release, Node.js, and the operating system
--help-hPrint the command-line help
--lang <lang>—Set the interface language: zh-CN, en, or auto (defaults to the system language; takes precedence over the NEOS_RELEASE_LANG environment variable)
--doctor—Environment diagnosis: check the Git, npm, and GitHub / GitLab credentials a release needs; only reads state and changes nothing
--offline—Used with --doctor: skip the checks that need network access (git fetch, npm registry connectivity, and login status)

Run Mode and Interface Options ​

OptionDescription
--ciSilent non-interactive mode that skips all confirmation prompts (enabled automatically in CI environments; force it off with --no-ci)
--only-versionHybrid mode: only the version selection (plus the publish confirmation / OTP when publishing to npm) is interactive; all other steps run automatically as in CI mode
--release-versionOnly calculate the next version and print it to stdout, with all other logs going to stderr, for easy capture in scripts
--only-changelogOnly generate the changelog for this release and print it to stdout, with all other logs going to stderr, for easy capture in scripts
--show-changelogPreview the full changelog for this release in the terminal when the release starts
--show-changesetPreview the list of staged files before the Git commit is created (git status --short --untracked-files=no)

Pre-release, PR, and Sync Mode Options ​

OptionDescription
--preRelease[=<id>]Enter pre-release mode, optionally with a pre-release identifier (such as --preRelease=beta); see Pre-releases, Snapshots & Canary
--preReleaseId=<id>Specify the pre-release identifier separately (such as alpha, rc)
--preReleaseBase=<num>Specify the starting pre-release number (for example 1 produces 1.0.0-beta.1 instead of .0)
--snapshot[=<id>]Snapshot version mode, producing 0.0.0-<id>.N versions; see Pre-releases, Snapshots & Canary
--canary[=<id>]Canary preview publishing, producing <next-version>-<id>.<YYYYMMDD>.g<shortSha> and restoring package.json automatically after publishing; see Canary Preview Releases
--pr / --no-prEnable or disable Release-via-PR mode; can be combined with sub-options such as --pr.draft, --pr.branch=..., and --pr.base=...; see Release-via-PR Mode
--sync-releases[=<vers>]Parse CHANGELOG.md to sync/backfill GitHub or GitLab Releases (accepts a comma-separated list of versions); see Sync Releases

Mutually exclusive modes: --canary, --snapshot, and --pr cannot be enabled at the same time; passing them together fails during configuration initialization.

Plugin Toggles and Nested Configuration Overrides ​

Every built-in plugin and nested configuration option can be toggled or overridden directly from the command line:

bash
# Disable a built-in plugin
release --no-git
release --no-npm
release --no-github
release --no-gitlab

# Enable / disable a specific sub-option
release --npm.publish --github.release
release --no-git.push --no-git.tag
release --npm.stage --npm.publishPackageManager=pnpm
release --pr --pr.draft --pr.base=main
release --sync-releases=v1.3.2,v1.3.1 --github.update

Nested sub-options use the exact camelCase key names (kebab-case is not converted to camelCase automatically).

Run Mode Comparison ​

FeatureDefault Interactive Mode--only-version--ci--release-version / --only-changelog
Screen clearing and welcome messageYesYesNoNo
Version selection promptYesYesNo (recommended version or patch is used automatically)No (calculated automatically)
Git / Changelog / Release confirmationsConfirmed step by stepRuns automaticallyRuns automaticallyThe release flow does not run
npm publish confirmation and 2FA interactionInteractive confirmation + inherits terminalInteractive confirmation + inherits terminalRuns automatically (does not inherit terminal)Not executed
stdout outputFull logs and interactive interfaceFull logs and interactive interfaceTask progress and logsPlain-text result only

Scripting Output Modes ​

Use --release-version or --only-changelog when a script or CI pipeline only needs the next version number or the changelog:

bash
# Print the next version
NEXT_VERSION=$(release --release-version)
NEXT_CANARY=$(release --canary --release-version)

# Export the changelog for this release
release --only-changelog > release-notes.md

Characteristics:

  • CI mode is entered automatically (no screen clearing, no welcome box, no interactive prompts).
  • The result goes directly to stdout, while warnings and auxiliary information are redirected to stderr, so piped content is not polluted.
  • Only the version is calculated or the changelog generated; no files are modified, and no Git commit or publish is performed.
  • If there is no new version or no changes are found, a notice is printed to stderr and the process exits with code 0.

Environment Diagnosis (--doctor) ​

Before releasing (or when troubleshooting a failed release), you can check the environment first. The command only reads state: it never logs in, modifies files, or pushes.

bash
release --doctor            # Check Git, npm, and GitHub / GitLab credentials
release --doctor --offline  # Skip checks that need network access (fetch, npm registry and login status)

The checks cover: the config file, the current branch and its upstream, whether the branch is behind upstream, a clean working tree, the Git identity, the latest tag, npm and registry connectivity and login status, GITHUB_TOKEN / the gh CLI, and GITLAB_TOKEN.

  • Each item is marked ✔ (passed), ⚠ (warning), ✘ (failed), or ⊘ (skipped); warning and failed items come with a suggested fix.
  • The command exits with code 1 when any check fails, and with 0 when everything passes or there are only warnings.

Cancelling a Release and Exit Codes ​

Cancelling with Ctrl+C (or Esc in a Prompt) ​

  • You can abort at any time during a release by pressing Ctrl+C; this is treated as a deliberate cancellation by the user rather than a failed release.
  • With the default git.requireCleanWorkingDir: true, local changes that have already been made (including the modified package.json, local commits, local tags, or the release PR branch) are rolled back synchronously before the process exits; commits or tags that have already been pushed to the remote are not rolled back.
  • In --canary mode, a cancellation or an error restores package.json to its original content exactly, without touching other uncommitted files in the working directory.

Exit Code Conventions ​

ScenarioExit codeDescription
Release succeeded0Normal completion
Cancelled with Ctrl+C / Esc in a terminal0A deliberate cancellation by someone who is present; avoids pnpm run release / npm run release misreporting the cancellation as an ELIFECYCLE failure
Interrupted by SIGINT without a terminal (CI, a pipe, or a runner terminating the job)130The flow did not complete; follows the 128 + 2 convention so the pipeline does not treat the interruption as a success; it is not reported as a failed release either
git.requireCommits: true with requireCommitsFail: false and no new commits0Treated as "nothing to release" and ends early normally
New commits but no releasable changes in CI mode (changelog.requireReleasableCommits: true)0Prints a notice that there is nothing releasable and skips this release
--sync-releases matched no versions to sync0Treated as nothing to sync and ends early normally
Configuration error, failed preflight check, or a failed hook or command1Prints the uniformly formatted error message and exits with a non-zero code
--doctor found a failed check1Prints every check with its result; exits with 0 when all checks pass or there are only warnings

The exit code is 0 when cancelling in a terminal, so if you chain commands in a shell (such as release && ./post-script.sh), the subsequent commands still run after a cancelled release; in programmatic usage you can distinguish a user cancellation with error.cancelled === true. Whether you are "in a terminal" is determined by whether stdin is a terminal: usages that redirect stdin, such as release < /dev/null, are handled with exit code 130 on cancellation.