
@neosjs/release
🚀 A universal CLI tool for version control that automates versioning and package publishing tasks
@neosjs/release is a universal CLI tool for version control and releasing. It automates version management, recommends the next version from releasable commits, generates a CHANGELOG.md with a contributors section, commits / tags / pushes with Git, runs safety preflight checks, publishes to npm, creates GitHub / GitLab Releases, handles Canary preview releases and Release-via-PR, backfills Releases from an existing changelog, and switches automatically between its English and Chinese interface.
Highlights
- Version management (
package.json) - Automatic version recommendation from releasable Conventional Commits (skipped automatically in CI when only non-releasable commits exist)
- Git operations: commit, tag (with GPG / SSH signature verification), push, and rollback on failure
- Run any test, build, or notification command with
Hooks - Changelog generation (
CHANGELOG.md) with a built-in contributors section (Contributors) and single-link PR entries - Publish to
NPM(supportspnpm/bun, 2FA, and staged publishing vianpm.stage) - Create Releases on
GitHub(supports environment-variable tokens, localghCLI credentials, and browser fallback) orGitLab - Manage pre-releases, snapshots, and Canary preview releases (
--canary) - Release-via-PR mode (
--pr) for repositories with a protected default branch - Safety preflight checks before releasing (upstream sync check, package contents scan, and warnings about potential breaking changes)
- Sync or backfill GitHub / GitLab Releases from
CHANGELOG.md(--sync-releases) - English & Chinese interface that switches automatically (follows the system language, overridable via
--lang/NEOS_RELEASE_LANG) - Extensible via plugins, and ready for any CI/CD environment
Documentation
- Basics & Configuration: Overview · Configuration · CLI Reference · Lifecycle Hooks · Environment Variables
- Core Capabilities: Git · Publish to npm · GitHub Releases · GitLab Releases · Changelog
- Advanced Modes & Operations: Pre-releases, Snapshots & Canary · Release-via-PR · Sync Releases · CI/CD Integration · Dry Runs & Troubleshooting
- Plugins & Recipes: Plugins & Authoring · Programmatic API · Protected Branch PR Pipeline · Custom Version Files · Release Only on New Commits
Installation
Although @neosjs/release is a universal release tool, it is most commonly used in projects with an npm package.
@neosjs/release requires Node.js >= 22.13.
The recommended way is to install it globally with npm and add some configuration to your project:
npm install @neosjs/release -gOr install it in your project and add a release script to package.json:
npm install @neosjs/release -Dpnpm add @neosjs/release -D{
"name": "package",
"version": "1.0.0",
"scripts": {
"release": "release"
},
"devDependencies": {
"@neosjs/release": "latest"
}
}Usage
Run @neosjs/release from your project root using npm run or npx:
npm run release
npx @neosjs/releaseIf @neosjs/release is installed globally, you can run it directly from your project root:
release
# or
neos-releaseYou will be prompted to select the next version, followed by further prompts based on your configuration.
Interface Language
The interface follows your system language by default (it detects LC_ALL / LC_MESSAGES / LANG and the system locale: Chinese is shown in Chinese environments, English everywhere else). You can override it explicitly (highest precedence first):
release --lang en # CLI flag (zh-CN / en / auto)
NEOS_RELEASE_LANG=en release # Environment variableYou can also set lang: 'zh-CN' | 'en' | 'auto' at the top level of your config file.
Reading the Version or Changelog in a Script
When you only need the version or the changelog, the two commands below print only the result to standard output (all other output goes to standard error), so they can be used directly in scripts:
VERSION=$(release --release-version)
release --only-changelog > notes.mdCancelling a Release
Pressing Ctrl+C during a release cancels it cleanly instead of treating it as a failure. With the default configuration (git.requireCleanWorkingDir enabled), the version bump, any commit already created, and any tag already created are rolled back; anything already pushed to a remote is not rolled back.
When cancelled from a terminal, the process exits with code 0: package managers treat a non-zero exit code as a failed script, for example pnpm reports ELIFECYCLE Command failed with exit code 1.. Accordingly, chained shell commands such as release && \<command\> still continue after a cancellation. Without a terminal on stdin (CI, a pipe, or a runner sending SIGINT), the exit code is 130 instead, so an interrupted run is not reported as a success by the pipeline.
For more configuration and usage options, run:
release --helpProgrammatic Usage
Besides the command line, you can also import the release function or the ReleaseManager class directly in a Node.js script:
import { ReleaseManager, release } from '@neosjs/release'
// Option 1: functional helper
const result = await release({
'ci': true,
'dry-run': true,
'git': { push: true }
})
// result: { name, latestVersion, version, changelog }
// Option 2: the ReleaseManager class
const manager = new ReleaseManager({
configOptions: {
ci: true,
git: { requireCleanWorkingDir: true, push: true }
}
})
try {
const { name, latestVersion, version, changelog } = await manager.release()
const config = manager.getConfig()
const logger = manager.getLogger()
logger.info(`${name}: ${latestVersion} -> ${version}`)
} catch (error: any) {
if (error?.cancelled) {
// The user cancelled the release (error.cancelled === true; error.code is 0 when stdin is a terminal, 130 otherwise)
} else {
console.error(error)
}
}new ReleaseManager({ configOptions, dependencyInjection }):configOptions: release options with higher priority than local config files, with the same structure as the CLI options.dependencyInjection: optional overrides for internal services (supportsconfig,log,shell,spinner,prompt, andinquirer), commonly used for custom logging or for writing tests.
manager.getContainer(),manager.getConfig(),manager.getLogger(): return the container, config, and logger instances; use them only aftermanager.release()has initialized the container.- The functional helper
release(options, dependencyInjection)is a convenience wrapper aroundReleaseManager, and always returnsPromise<{ name, latestVersion, version, changelog }>. - Used as a library,
release()never terminates the host process: it resolves with the result on success, rejects witherror.code === 0on an early exit (for example, when there is nothing to release), and rejects witherror.code === 1on a failed release; the exit code is up to the caller.
See Programmatic API for more usage and dependency injection examples.