Configuration Guide
@neosjs/release works out of the box with a complete set of built-in defaults. You only need to write the options you want to override in a configuration file.
Supported Configuration Files
Built on c12, the tool automatically looks for the following configuration files in the project root:
release.config.tsrelease.config.js/release.config.mjs/release.config.cjsrelease.config.jsonrelease.config.yaml/release.config.ymlrelease.config.toml- The
"release.config"field inpackage.json
You can also pass a custom path with -c / --config on the command line, or disable local configuration files with --no-config:
release --config ./config/release.prod.ts
release --no-configTypeScript Configuration (Recommended)
Use defineConfig together with ConfigOptions to get full type checking and editor autocompletion:
import { type ConfigOptions, defineConfig } from '@neosjs/release'
export default defineConfig({
changelog: {
generate: true,
header: '# Changelog\n\nThis changelog is automatically updated by `@neosjs/release`.\n',
infile: 'CHANGELOG.md'
},
git: {
commitMessage: 'chore: release v${version}',
push: true,
requireCommits: true,
requireCommitsFail: false
},
npm: {
publish: true
},
github: {
release: true
}
}) satisfies ConfigOptions{
"git": {
"commitMessage": "chore: release v${version}",
"push": true
},
"npm": {
"publish": true
}
}export default {
git: {
push: true
},
github: {
release: true
}
}git:
push: true
commitMessage: "chore: release v${version}"
npm:
publish: trueExtending Configuration
Thanks to the configuration inheritance provided by c12, you can reuse shared team configuration through extends (local paths, npm packages and Git repositories are supported):
{
"extends": [
"./release.base.json",
"@my-org/release-config"
],
"npm": {
"publish": true
}
}Priority and Merge Rules
The final configuration is deep-merged in the following order, from highest to lowest priority:
- Command-line arguments /
configOptionspassed programmatically (highest priority) - Automatic CI detection (sets
ci: trueautomatically throughci-info; override with--no-ci) - Local configuration file (including configuration inherited through
extends) - Built-in defaults (lowest priority)
Merge Behavior to Watch Out For
- Arrays are replaced as a whole, not merged item by item: When you configure an array option, it directly replaces the default array and the remaining elements of the default are not kept. For example, configuring only
git.pushArgs: ['--force-with-lease']does not implicitly add the default--follow-tags, and an empty array[]stays empty. Likewise, listing only a few items inchangelog.preset.typeskeeps only those items (whilepreset.name: 'conventionalcommits'is still kept). - Explicit
nullis preserved: for example,changelog.infile: nullis not replaced by the default'CHANGELOG.md'. undefineddoes not override lower-priority values: options not passed on the command line or in a programmatic call do not wipe out the local configuration.- Disabling a built-in plugin as a whole: setting a plugin to
false(such asgit: false,npm: false,github: false,gitlab: false) keeps itfalse; it is not expanded into the default object. - The
prboolean shorthand is deep-merged with objects: after writingpr: { draft: true, branch: 'rel/v${version}' }in the configuration file, passing--pron the command line normalizes it to{ pr: { enabled: true } }and merges it with the localprobject, so the other fields are not lost.
Overriding Configuration from the Command Line
Any nested option can be overridden directly on the command line with a dot path (.):
release --git.commitMessage="release: v\${version}" --npm.publish --github.releaseUse the --no- prefix to set a boolean option to false or to disable an entire built-in plugin:
release --no-git.push
release --no-npm
release --no-npm.checkFiles
release --no-git.requireCleanWorkingDirCase matters: CLI argument parsing has
camel-case-expansiondisabled, so nested options must use the exact camelCase spelling used in the configuration object (for example--git.requireUpToDate,--npm.checkBreakingChanges,--github.autoGenerate, not--git.require-up-to-date).
Template Interpolation
@neosjs/release uses the Eta template engine to render ${...} placeholders. This applies to git.commitMessage, git.tagName, git.tagAnnotation, git.logCommand, github.releaseName, github.assets, github.comments.*, gitlab.releaseName, gitlab.milestones, gitlab.assets, pr.branch, pr.title, pr.body and all hooks commands.
Security note: what goes inside
${...}is a JavaScript expression that gets evaluated, not just a placeholder, and the commands inhooks,git.logCommandand string-valuedreleaseNotesare ultimately handed to the system shell. Templates and commands should come only from configuration that you maintain yourself; never assemble them from environment variables or external input. When a template fails to render, only the faulty template and the reason are printed, never the context. In these command templates, execution is refused when a variable's value contains shell syntax (whitespace, quotes,$,;,|,&, etc.). For multi-line text such as the changelog, use the environment variables described below instead. See Lifecycle hooks - Template variable values and the shell.
The commonly used context variables are listed below:
| Variable | Description | Example value |
|---|---|---|
${version} | Target version of this release | 1.4.0 |
${latestVersion} | Latest version before the release | 1.3.3 |
${name} | Project name (name from package.json if available, otherwise the Git repository name) | @neosjs/release |
${tagName} | Git tag name of this release | v1.4.0 |
${latestTag} | Git tag name of the previous release | v1.3.3 |
${secondLatestTag} | Second-to-last Git tag name (resolved with --no-increment) | v1.3.2 |
${branchName} | Current Git branch name | main |
${remoteUrl} | Resolved Git remote URL | git@github.com:NeosJS/release-core.git |
${repo.protocol} | Remote protocol (https / ssh / file) | ssh |
${repo.host} | Remote host name (ssh.github.com is normalized to github.com) | github.com |
${repo.owner} | Repository owner / organization name | NeosJS |
${repo.project} | Repository project name | release-core |
${repo.repository} | Full owner/project repository path | NeosJS/release-core |
${repo.remote} | Normalized remote repository URL | https://github.com/NeosJS/release-core |
${changelog} | Body of the changelog generated for this release | ### ✨ Features ... |
${isPreRelease} | Whether the target version is a pre-release | false |
${preReleaseId} | Pre-release identifier (such as beta; null when not a pre-release) | beta |
${npm.name} | Package name from package.json | @neosjs/release |
${npm.tag} | dist-tag used when publishing to npm | latest |
${releaseName} | Release title on the hosting platform (available in contexts such as GitHub/GitLab comments) | Release 1.4.0 |
${releaseUrl} | Link to the GitHub / GitLab Release that was created (available in afterRelease and comment contexts) | https://github.com/.../releases/tag/v1.4.0 |
${isReleased} | Whether a GitHub / GitLab Release has been created | true |
${discussionUrl} | Link to the Discussion attached to the GitHub Release (undefined when there is none) | https://github.com/.../discussions/12 |
${prBranch} | Release branch created in Release-via-PR mode | release/v1.4.0 |
${baseBranch} | Target branch to merge into in Release-via-PR mode | main |
${originalBranch} | Branch you were on before the release in Release-via-PR mode | main |
${prUrl} | Link to the PR or MR after it is created/updated in Release-via-PR mode (available in after:pr:release / after:release) | https://github.com/.../pull/26 |
${prAction} | Result for the PR / MR: created, updated, or web (fell back to opening the browser) | created |
${prMethod} | How the PR / MR was created: gh (gh CLI), api or web | api |
Using Environment Variables in Command Templates
hooks, git.logCommand and string-valued releaseNotes are ultimately handed to the system shell, while values such as ${branchName}, ${latestTag} and ${changelog} come from the repository itself. A value rendered into a command therefore must not contain shell syntax (otherwise execution is refused). For multi-line text or content with special characters, use environment variables instead: the variables in the table above (except ${releaseName}) are also passed to the command as environment variables, named in snake case with a RELEASE_ prefix, so quoting the variable name in the command reads the value verbatim.
| Template variable | Environment variable |
|---|---|
${version} | $RELEASE_VERSION |
${branchName} | $RELEASE_BRANCH_NAME |
${repo.owner} | $RELEASE_REPO_OWNER |
${changelog} | $RELEASE_CHANGELOG |
export default defineConfig({
hooks: {
// The changelog is multi-line text: use the environment variable, not ${changelog}
'after:bump': 'printf "%s" "$RELEASE_CHANGELOG" > release-notes.md'
}
})Configuration options are not part of these environment variables (they may contain sensitive values such as npm.otp); only values produced during the release are passed to commands.
Top-Level Options
| Option | Type | Default | Description |
|---|---|---|---|
| lang | 'auto' | 'zh-CN' | 'en' | 'auto' | Interface language: with 'auto', the language is detected automatically from the NEOS_RELEASE_LANG environment variable and then the system locale (LC_ALL / LC_MESSAGES / LANG / Intl); Chinese is shown in Chinese-language environments and English everywhere else |
Configuration Reference by Module
- Git options
- npm options
- GitHub options
- GitLab options
- Changelog options
- Release-via-PR options
- Lifecycle hooks configuration
- External plugin configuration
Complete Default Configuration
The following are all built-in defaults of @neosjs/release (kept in sync with src/defaultConfig.ts in the source code):
export default {
lang: 'auto',
hooks: {},
plugins: {},
changelog: {
generate: true,
header: '# Changelog\n',
infile: 'CHANGELOG.md',
ignoreRecommendedBump: false,
requireReleasableCommits: true,
contributors: true,
contributorsLookup: true,
contributorsEmail: false,
preset: {
name: 'conventionalcommits',
types: [
{ section: '✨ Features', type: 'feat', release: 'minor' },
{ section: '🐛 Bug Fixes', type: 'fix', release: 'patch' },
{ section: '🔥 Performance Improvements', type: 'perf', release: 'patch' },
{ section: '🔙 Reverts', type: 'revert', release: 'patch' },
{ section: '📚 Documentation', type: 'docs', hidden: true },
{ section: '💅 Code Refactoring', type: 'refactor', hidden: true },
{ section: '🎨 Code Style Changes', type: 'style', hidden: true },
{ section: '✅ Tests', type: 'test', hidden: true },
{ section: '🏗️ Build Changes', type: 'build', hidden: true },
{ section: '🤖 Continuous Integration', type: 'ci', hidden: true },
{ section: '🏡 Chores', type: 'chore', hidden: true }
]
}
},
git: {
logCommand: 'git log --pretty=format:"* %s (%h)" ${from}...${to}',
requireCleanWorkingDir: true,
requireBranch: false,
requireUpstream: true,
requireUpToDate: true,
requireCommits: false,
requireCommitsFail: true,
commitsPath: '',
addUntrackedFiles: false,
commit: true,
commitMessage: 'chore: release v${version}',
commitArgs: [],
tag: true,
tagExclude: null,
tagName: 'v${version}',
tagMatch: null,
getLatestTagFromAllRefs: false,
tagAnnotation: 'Release v${version}',
tagArgs: [],
push: true,
pushArgs: ['--follow-tags'],
pushRepo: ''
},
npm: {
publish: false,
publishPath: '.',
publishArgs: [],
publishPackageManager: 'npm',
tag: null,
stage: false,
otp: null,
ignoreVersion: false,
allowSameVersion: false,
versionArgs: [],
skipChecks: false,
checkFiles: true,
checkBreakingChanges: true,
strictChecks: false,
timeout: 10
},
github: {
release: false,
releaseName: 'Release v${version}',
releaseNotes: null,
autoGenerate: false,
preRelease: false,
draft: false,
update: false,
tokenRef: 'GITHUB_TOKEN',
assets: null,
host: null,
timeout: 0,
proxy: null,
makeLatest: true,
skipChecks: false,
web: false,
comments: {
submit: false,
issue: ':rocket: _This issue has been resolved in ${tagName}. See [${releaseName}](${releaseUrl}) for release notes._',
pr: ':rocket: _This pull request is included in ${tagName}. See [${releaseName}](${releaseUrl}) for release notes._'
}
},
gitlab: {
release: false,
releaseName: 'Release v${version}',
releaseNotes: null,
milestones: [],
update: false,
tokenRef: 'GITLAB_TOKEN',
tokenHeader: 'Private-Token',
certificateAuthorityFile: null,
certificateAuthorityFileRef: 'CI_SERVER_TLS_CA_FILE',
secure: true,
proxy: false,
assets: null,
useIdsForUrls: false,
useGenericPackages: false,
genericPackageName: '',
origin: null,
skipChecks: false,
repoId: null
},
pr: {
enabled: false,
branch: 'release/v${version}',
base: '',
title: 'chore: release v${version}',
body: null,
draft: false,
forcePush: true
}
}