Skip to content

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.ts
  • release.config.js / release.config.mjs / release.config.cjs
  • release.config.json
  • release.config.yaml / release.config.yml
  • release.config.toml
  • The "release.config" field in package.json

You can also pass a custom path with -c / --config on the command line, or disable local configuration files with --no-config:

bash
release --config ./config/release.prod.ts
release --no-config

Use defineConfig together with ConfigOptions to get full type checking and editor autocompletion:

ts
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
json
{
  "git": {
    "commitMessage": "chore: release v${version}",
    "push": true
  },
  "npm": {
    "publish": true
  }
}
js
export default {
  git: {
    push: true
  },
  github: {
    release: true
  }
}
yaml
git:
  push: true
  commitMessage: "chore: release v${version}"
npm:
  publish: true

Extending 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):

json
{
  "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:

  1. Command-line arguments / configOptions passed programmatically (highest priority)
  2. Automatic CI detection (sets ci: true automatically through ci-info; override with --no-ci)
  3. Local configuration file (including configuration inherited through extends)
  4. 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 in changelog.preset.types keeps only those items (while preset.name: 'conventionalcommits' is still kept).
  • Explicit null is preserved: for example, changelog.infile: null is not replaced by the default 'CHANGELOG.md'.
  • undefined does 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 as git: false, npm: false, github: false, gitlab: false) keeps it false; it is not expanded into the default object.
  • The pr boolean shorthand is deep-merged with objects: after writing pr: { draft: true, branch: 'rel/v${version}' } in the configuration file, passing --pr on the command line normalizes it to { pr: { enabled: true } } and merges it with the local pr object, 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 (.):

bash
release --git.commitMessage="release: v\${version}" --npm.publish --github.release

Use the --no- prefix to set a boolean option to false or to disable an entire built-in plugin:

bash
release --no-git.push
release --no-npm
release --no-npm.checkFiles
release --no-git.requireCleanWorkingDir

Case matters: CLI argument parsing has camel-case-expansion disabled, 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 in hooks, git.logCommand and string-valued releaseNotes are 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:

VariableDescriptionExample value
${version}Target version of this release1.4.0
${latestVersion}Latest version before the release1.3.3
${name}Project name (name from package.json if available, otherwise the Git repository name)@neosjs/release
${tagName}Git tag name of this releasev1.4.0
${latestTag}Git tag name of the previous releasev1.3.3
${secondLatestTag}Second-to-last Git tag name (resolved with --no-increment)v1.3.2
${branchName}Current Git branch namemain
${remoteUrl}Resolved Git remote URLgit@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 nameNeosJS
${repo.project}Repository project namerelease-core
${repo.repository}Full owner/project repository pathNeosJS/release-core
${repo.remote}Normalized remote repository URLhttps://github.com/NeosJS/release-core
${changelog}Body of the changelog generated for this release### ✨ Features ...
${isPreRelease}Whether the target version is a pre-releasefalse
${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 npmlatest
${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 createdtrue
${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 moderelease/v1.4.0
${baseBranch}Target branch to merge into in Release-via-PR modemain
${originalBranch}Branch you were on before the release in Release-via-PR modemain
${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 webapi

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 variableEnvironment variable
${version}$RELEASE_VERSION
${branchName}$RELEASE_BRANCH_NAME
${repo.owner}$RELEASE_REPO_OWNER
${changelog}$RELEASE_CHANGELOG
ts
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 ​

OptionTypeDefaultDescription
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 ​

Complete Default Configuration ​

The following are all built-in defaults of @neosjs/release (kept in sync with src/defaultConfig.ts in the source code):

ts
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
  }
}