release-it
CLI release tool for Git repos and npm packages.
Last updated 10 days ago by webpro .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install release-it 
SYNC missed versions from official npm registry.

Release It! ????

CLI release tool for Git repos and npm packages.

Release It! automates the tedious tasks of software releases:

Build Status npm version codecov

Links

<summary>Table of Contents (click to expand)</summary>

Installation

Although release-it is a generic release tool, installation requires npm. A package.json file is not required. The recommended way to install release-it also adds basic configuration. Answer one or two questions and it's ready:

npm init release-it

Alternatively, install it manually, and add the release script to package.json:

npm install --save-dev release-it
{
  "name": "my-package",
  "version": "1.0.0",
  "scripts": {
    "release": "release-it"
  },
  "devDependencies": {
    "release-it": "*"
  }
}

Now you can run npm run release from the command line (any release-it arguments behind the --):

npm run release
npm run release -- minor --ci

Global usage

Use release-it in any (non-npm) project, take it for a test drive, or install it globally:

# Run release-it from anywhere (without installation)
npx release-it

# Install globally and run from anywhere
npm install --global release-it
release-it

Usage

Release a new version:

release-it

You will be prompted to select the new version. To skip the first prompt, provide a specific increment or version:

release-it minor
release-it 0.8.3

For a "dry run", to show the interactivity and the commands it would execute:

release-it --dry-run

Note: read-only commands are still executed ($ ...), while the rest is not (! ...):

$ git rev-parse --git-dir
.git
! git add package.json
! git commit --message="Release 0.8.3"

Configuration

Out of the box, release-it has sane defaults, and plenty of options to configure it. Put (only) the options to override in a configuration file. This is where release-it looks for configuration:

  • .release-it.json
  • .release-it.js (export the configuration object: module.exports = {})
  • .release-it.yaml (or .yml)
  • .release-it.toml
  • package.json (in the release-it property)

Use --config to use another path for the configuration file. An example .release-it.json:

{
  "git": {
    "tagName": "v${version}"
  },
  "github": {
    "release": true
  }
}

Or in a release-it property in package.json:

{
  "name": "my-package",
  "devDependencies": {
    "release-it": "*"
  },
  "release-it": {
    "github": {
      "release": true
    }
  }
}

Or use YAML in .release-it.yml:

git:
  commitMessage: 'chore: release v${version}'

Or TOML in .release-it.toml:

[hooks]
before:init = "npm test"

Any option can also be set on the command-line, and will have highest priority. Example:

release-it minor --git.tagName='v${version}' --github.release

Boolean arguments can be negated by using the no- prefix:

release-it --no-npm.publish

Interactive vs. CI mode

By default, release-it is interactive and allows you to confirm each task before execution:

By using the --ci option, the process is fully automated without prompts. The configured tasks will be executed as demonstrated in the first animation above. On a Continuous Integration (CI) environment, this non-interactive mode is activated automatically.

Note: the old -n (or --non-interactive) option still works and is identical to --ci.

Latest version

For projects with a package.json, its version will be used. Otherwise, release-it uses the latest Git tag to determine which version should be released. In any case, as a last resort, 0.0.0 will be used as the latest version.

Use --no-increment to not increment the version.

Use --no-npm (or "npm": false) to ignore and skip bumping package.json (and skip npm publish).

Alternatively, a plugin can be used to get the version from anywhere else (e.g. a VERSION file). Also see plugins.

Prerequisite checks

Read more about prerequisites checks release-it does to help prevent incorrect or polluted releases.

Git

SSH keys & Git remotes

SSH keys and Git remotes are assumed to be configured correctly. If a manual git push from the command line works, release-it should be able to do the same.

The following help pages might be useful: SSH and Managing Remotes (GitHub), SSH keys (Bitbucket), SSH keys (GitLab).

Remote repository

By default, release-it uses "origin" as the remote name to push to. Use git.pushRepo to override this with a different remote name (or a different git url).

Extra arguments

In case extra arguments should be provided to Git, these options are available:

  • git.commitArgs
  • git.tagArgs
  • git.pushArgs

For example, use "git.commitArgs": "-S" to sign commits (also see #35).

Skip Git steps

To skip the Git steps (commit, tag, push) entirely (e.g. to only npm publish), use the shorthand:

release-it --no-git

Use e.g. git.tag: false or --no-git.tag to skip a single step.

Untracked files

By default, untracked files are not added to the release commit. Use git.addUntrackedFiles: true to override this behavior.

GitHub Releases

The "Releases" tab on GitHub projects links to a page to store the changelog cq. release notes. To add GitHub releases in your release-it flow:

  • Configure github.release: true.
  • Obtain a personal access token (release-it only needs "repo" access; no "admin" or other scopes).
  • Make sure the token is available as an environment variable. Example:
export GITHUB_TOKEN="f941e0..."

→ See GitHub Releases for more details.

GitLab Releases

GitLab releases work just like GitHub releases:

  • Configure gitlab.release: true.
  • Obtain a personal access token (release-it only needs the "api" scope).
  • Make sure the token is available as an environment variable. Example:
export GITLAB_TOKEN="f941e0..."

→ See GitLab Releases for more details.

Changelog

By default, release-it generates a changelog, to show and help select a version for the new release. Additionally, this changelog serves as the release notes for the GitHub or GitLab release.

The default command is based on git log .... This setting (git.changelog) can be overridden. To customize the release notes for the GitHub or GitLab release, use github.releaseNotes or gitlab.releaseNotes. Make sure any of these commands output the changelog to stdout.

Instead of executing a shell command, a (Handlebars) template can be used to generate the changelog. See auto-changelog for more details. If your project follows conventions, such as the Angular commit guidelines, the @release-it/conventional-changelog plugin is useful.

→ See Changelog for more details.

Publish to npm

With a package.json in the current directory, release-it will let npm bump the version in package.json (and package-lock.json if present), and publish to the npm registry.

→ See Publish to npm for more details.

Manage pre-releases

With release-it, it's easy to create pre-releases: a version of your software that you want to make available, while it's not in the stable semver range yet. Often "alpha", "beta", and "rc" (release candidate) are used as identifier for pre-releases.

An example. The awesome-pkg is at version 1.3.0, and work is done for a new major update. To publish the latest beta of the new major version:

release-it major --preRelease=beta

This will tag and release version 2.0.0-beta.0. Notes:

  • A normal installation of awesome-pkg will still be at version 1.3.0.
  • The npm tag will be "beta", install it using npm install awesome-pkg@beta
  • A GitHub release will be marked as a "Pre-release".

The above command is actually a shortcut for:

release-it premajor --preReleaseId=beta --npm.tag=beta --github.preRelease

Consecutive beta releases (2.0.0-beta.1 and so on):

release-it --preRelease

And when ready to release the next phase (e.g. release candidate, in this case 2.0.0-rc.0):

release-it --preRelease=rc

And eventually, for 2.0.0:

release-it major

Notes:

  • Pre-releases work in tandem with recommended bumps.
  • You can still override individual options, e.g. release-it --preRelease=rc --npm.tag=next.
  • See semver.org for more details about semantic versioning.

Hooks

Use script hooks to run shell commands at any moment during the release process. The format is [prefix]:[hook] or [prefix]:[namespace]:[hook]:

part value
prefix before or after
namespace version, git, npm, github, gitlab or [plugin-name]
hook init, beforeBump, bump, beforeRelease, release or afterRelease

Use the optional namespace to precisely hook into a life cycle method between specific plugins. The core namespaces (plugins) include version, git, npm, github, gitlab. When using a custom plugin, that namespace will also be available (e.g. @release-it/conventional-changelog has the conventional-changelog namespace).

See execution order for more details on execution order of plugin lifecycle methods.

All commands can use configuration variables (like template strings). An array of commands can also be provided, they will run one after another. Some examples:

{
  "hooks": {
    "before:init": ["npm run lint", "npm test"],
    "after:my-plugin:bump": "./bin/my-script.sh",
    "after:bump": "npm run build",
    "after:git:release": "echo After git push, before github release",
    "after:release": "echo Successfully released ${name} v${version} to ${repo.repository}."
  }
}

The variables can be found in the default configuration. Additionally, the following variables are exposed:

version
latestVersion
changelog
name
repo.remote, repo.protocol, repo.host, repo.owner, repo.repository, repo.project

All variables are available in all hooks. The only exception is that the additional variables listed above are not available in the init hook.

Scripts (deprecated)

Please use hooks instead, as hooks are more flexible. The scripts will stay for a while, but will be removed in a few major releases after v12. Here's how to migrate:

  • scripts.beforeStarthooks.before:init
  • scripts.beforeBumphooks.before:bump
  • scripts.afterBumphooks.after:bump
  • scripts.beforeStagehooks.after:bump
  • scripts.afterReleasehooks.after:release

Plugins

Since v11, release-it can be extended in many, many ways.

→ See plugins for more details.

Distribution repository

Some projects use a distribution repository. Generated files (such as compiled assets or documentation) can be distributed to a separate repository. Or to a separate branch, such as a gh-pages. Some examples include shim repositories and a separate packaged Angular.js repository for distribution on npm and Bower.

The dist.repo option was removed in v10, but similar setups can still be achieved. Please see the distribution repository recipe for example configurations.

Metrics

Use --disable-metrics to opt-out of sending some anonymous statistical data to Google Analytics. For details, refer to lib/metrics.js. Please consider to not opt-out: more data means more support for future development.

Troubleshooting & debugging

  • With release-it --verbose, release-it prints every command and its output.
  • Prepend DEBUG=release-it:* release-it [...] to print configuration and more error details.
  • Use DEBUG=* release-it [...] to include debug output for dependencies, such as @octokit/rest.

Use release-it programmatically

While mostly used as a CLI tool, release-it can be used as a dependency to ingrate in your own scripts. See use release-it programmatically for example code.

Example projects using release-it

Resources

Credits

Major dependencies:

The following Grunt plugins have been a source of inspiration:

Current Tags

  • 11.0.0-alpha.7                                ...           alpha (3 months ago)
  • 11.0.0-beta.4                                ...           beta (3 months ago)
  • 12.3.3                                ...           latest (10 days ago)
  • 12.3.0-next.1                                ...           next (2 months ago)
  • 11.0.0-rc.1                                ...           rc (3 months ago)

216 Versions

  • 12.3.3                                ...           10 days ago
  • 12.3.2                                ...           16 days ago
  • 12.3.1                                ...           16 days ago
  • 12.3.0                                ...           2 months ago
  • 12.2.2                                ...           2 months ago
  • 12.3.0-next.1                                ...           2 months ago
  • 12.3.0-next.0                                ...           2 months ago
  • 12.2.1                                ...           2 months ago
  • 12.2.0                                ...           2 months ago
  • 12.1.0                                ...           2 months ago
  • 11.0.4                                ...           3 months ago
  • 12.0.1                                ...           3 months ago
  • 12.0.0                                ...           3 months ago
  • 11.0.3                                ...           3 months ago
  • 11.0.2                                ...           3 months ago
  • 11.0.1                                ...           3 months ago
  • 11.0.0                                ...           3 months ago
  • 11.0.0-rc.1                                ...           3 months ago
  • 10.4.5                                ...           3 months ago
  • 11.0.0-rc.0                                ...           3 months ago
  • 11.0.0-beta.4                                ...           3 months ago
  • 11.0.0-beta.3                                ...           3 months ago
  • 10.4.4                                ...           3 months ago
  • 10.4.3                                ...           3 months ago
  • 11.0.0-beta.2                                ...           3 months ago
  • 11.0.0-beta.1                                ...           3 months ago
  • 11.0.0-beta.0                                ...           3 months ago
  • 10.4.2                                ...           3 months ago
  • 11.0.0-alpha.7                                ...           3 months ago
  • 10.4.1                                ...           3 months ago
  • 11.0.0-alpha.6                                ...           3 months ago
  • 11.0.0-alpha.5                                ...           3 months ago
  • 11.0.0-alpha.4                                ...           3 months ago
  • 11.0.0-alpha.3                                ...           3 months ago
  • 11.0.0-alpha.2                                ...           3 months ago
  • 11.0.0-alpha.1                                ...           3 months ago
  • 11.0.0-alpha.0                                ...           3 months ago
  • 10.4.0                                ...           4 months ago
  • 10.4.0-0                                ...           4 months ago
  • 10.3.1                                ...           4 months ago
  • 10.3.0                                ...           4 months ago
  • 10.2.0                                ...           5 months ago
  • 10.1.0                                ...           5 months ago
  • 10.0.7                                ...           6 months ago
  • 10.0.6                                ...           6 months ago
  • 10.0.4                                ...           6 months ago
  • 10.0.3                                ...           6 months ago
  • 9.8.3                                ...           6 months ago
  • 10.0.2                                ...           6 months ago
  • 10.0.1                                ...           6 months ago
  • 9.8.2                                ...           6 months ago
  • 10.0.0                                ...           6 months ago
  • 10.0.0-rc.2                                ...           6 months ago
  • 10.0.0-rc.1                                ...           6 months ago
  • 10.0.0-rc.0                                ...           6 months ago
  • 9.8.1                                ...           6 months ago
  • 9.8.0                                ...           6 months ago
  • 9.7.1                                ...           6 months ago
  • 9.7.0                                ...           6 months ago
  • 9.6.5                                ...           6 months ago
  • 9.6.4                                ...           6 months ago
  • 9.6.3                                ...           6 months ago
  • 9.6.2                                ...           6 months ago
  • 9.6.1                                ...           6 months ago
  • 9.6.0                                ...           6 months ago
  • 9.5.1                                ...           7 months ago
  • 9.5.0                                ...           7 months ago
  • 9.4.4                                ...           7 months ago
  • 9.4.3                                ...           7 months ago
  • 9.4.2                                ...           7 months ago
  • 9.4.1                                ...           7 months ago
  • 9.4.0                                ...           7 months ago
  • 9.3.0                                ...           7 months ago
  • 9.2.0                                ...           7 months ago
  • 9.1.0                                ...           7 months ago
  • 9.0.1                                ...           7 months ago
  • 9.0.0                                ...           7 months ago
  • 9.0.0-beta.4                                ...           7 months ago
  • 9.0.0-beta.3                                ...           7 months ago
  • 8.4.3                                ...           7 months ago
  • 9.0.0-beta.2                                ...           7 months ago
  • 9.0.0-beta.1                                ...           7 months ago
  • 9.0.0-beta.0                                ...           7 months ago
  • 8.4.2                                ...           7 months ago
  • 8.4.1                                ...           7 months ago
  • 8.4.0                                ...           7 months ago
  • 8.3.1                                ...           7 months ago
  • 8.3.0                                ...           7 months ago
  • 8.2.0                                ...           8 months ago
  • 8.1.0                                ...           8 months ago
  • 8.0.1                                ...           8 months ago
  • 8.0.0                                ...           8 months ago
  • 7.7.0-try.0                                ...           8 months ago
  • 7.6.3                                ...           8 months ago
  • 7.6.3-beta.0                                ...           8 months ago
  • 7.6.2                                ...           9 months ago
  • 7.6.1                                ...           a year ago
  • 7.6.0                                ...           a year ago
  • 7.5.1                                ...           a year ago
  • 7.5.0                                ...           a year ago
  • 7.5.0-beta.0                                ...           a year ago
  • 7.4.8                                ...           a year ago
  • 7.4.7                                ...           a year ago
  • 7.4.6                                ...           a year ago
  • 7.4.5                                ...           a year ago
  • 7.4.4                                ...           a year ago
  • 7.4.3                                ...           a year ago
  • 7.4.2                                ...           a year ago
  • 7.4.1                                ...           a year ago
  • 7.4.0                                ...           a year ago
  • 7.3.0                                ...           a year ago
  • 7.2.1                                ...           a year ago
  • 7.2.0                                ...           a year ago
  • 7.1.0                                ...           a year ago
  • 7.0.2                                ...           a year ago
  • 7.0.1                                ...           a year ago
  • 7.0.0                                ...           a year ago
  • 6.2.0                                ...           a year ago
  • 6.1.1                                ...           a year ago
  • 6.1.0                                ...           a year ago
  • 6.0.0                                ...           2 years ago
  • 6.0.0-rc.0                                ...           2 years ago
  • 5.2.0                                ...           2 years ago
  • 5.1.3                                ...           2 years ago
  • 5.2.0-rc.0                                ...           2 years ago
  • 6.0.0-alpha.1                                ...           2 years ago
  • 6.0.0-alpha.0                                ...           2 years ago
  • 5.1.2                                ...           2 years ago
  • 5.2.0-alpha.0                                ...           2 years ago
  • 5.1.1                                ...           2 years ago
  • 5.1.0                                ...           2 years ago
  • 5.0.1                                ...           2 years ago
  • 5.0.0                                ...           2 years ago
  • 5.0.0-beta.1                                ...           2 years ago
  • 5.0.0-beta.0                                ...           2 years ago
  • 4.4.1                                ...           2 years ago
  • 4.5.0-alpha.0                                ...           2 years ago
  • 4.4.0                                ...           2 years ago
  • 3.2.0                                ...           2 years ago
  • 2.9.0                                ...           2 years ago
  • 4.3.0                                ...           2 years ago
  • 4.2.0                                ...           2 years ago
  • 4.1.1                                ...           2 years ago
  • 4.1.0                                ...           2 years ago
  • 4.0.0                                ...           2 years ago
  • 4.0.0-rc.1                                ...           2 years ago
  • 4.0.0-rc.0                                ...           2 years ago
  • 3.1.2                                ...           2 years ago
  • 3.1.1                                ...           2 years ago
  • 3.1.0                                ...           2 years ago
  • 3.1.0-beta.1                                ...           2 years ago
  • 3.1.0-beta.0                                ...           2 years ago
  • 3.0.2                                ...           2 years ago
  • 3.0.1                                ...           2 years ago
  • 3.0.0                                ...           2 years ago
  • 3.0.0-beta.7                                ...           2 years ago
  • 3.0.0-beta.6                                ...           2 years ago
  • 3.0.0-beta.5                                ...           2 years ago
  • 3.0.0-beta.4                                ...           2 years ago
  • 3.0.0-beta.3                                ...           2 years ago
  • 3.0.0-beta.2                                ...           2 years ago
  • 3.0.0-beta.1                                ...           2 years ago
  • 3.0.0-beta.0                                ...           2 years ago
  • 2.8.5                                ...           2 years ago
  • 2.8.4                                ...           2 years ago
  • 2.8.3                                ...           2 years ago
  • 2.8.2                                ...           2 years ago
  • 2.8.0                                ...           2 years ago
  • 2.7.3                                ...           2 years ago
  • 2.7.2                                ...           2 years ago
  • 2.7.1                                ...           2 years ago
  • 2.7.0                                ...           2 years ago
  • 2.6.1                                ...           2 years ago
  • 2.6.0                                ...           2 years ago
  • 2.5.4                                ...           2 years ago
  • 2.5.3                                ...           3 years ago
  • 2.5.2                                ...           3 years ago
  • 2.5.1                                ...           3 years ago
  • 2.5.0                                ...           3 years ago
  • 2.4.3                                ...           3 years ago
  • 2.4.2                                ...           3 years ago
  • 2.4.1                                ...           3 years ago
  • 2.4.0                                ...           3 years ago
  • 2.3.1                                ...           4 years ago
  • 2.3.0                                ...           4 years ago
  • 2.2.2                                ...           4 years ago
  • 2.2.1                                ...           4 years ago
  • 2.2.0                                ...           4 years ago
  • 2.1.0                                ...           4 years ago
  • 2.0.3                                ...           4 years ago
  • 2.0.2                                ...           4 years ago
  • 2.0.1                                ...           4 years ago
  • 2.0.0                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
  • 0.1.5                                ...           4 years ago
  • 0.1.4                                ...           4 years ago
  • 0.1.3                                ...           4 years ago
  • 0.1.2                                ...           4 years ago
  • 0.1.1                                ...           4 years ago
  • 0.1.0                                ...           4 years ago
  • 0.0.18                                ...           4 years ago
  • 0.0.17                                ...           4 years ago
  • 0.0.16                                ...           4 years ago
  • 0.0.15                                ...           5 years ago
  • 0.0.14                                ...           5 years ago
  • 0.0.13                                ...           5 years ago
  • 0.0.12                                ...           5 years ago
  • 0.0.11                                ...           5 years ago
  • 0.0.10                                ...           5 years ago
  • 0.0.9                                ...           5 years ago
  • 0.0.5                                ...           5 years ago
  • 0.0.2                                ...           6 years ago
  • 0.0.6                                ...           5 years ago
  • 0.0.4                                ...           5 years ago
  • 0.0.3                                ...           6 years ago
  • 0.0.1                                ...           6 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1,610
Last Day 4
Last Week 156
Last Month 1,344
Dependencies (28)
Dev Dependencies (16)
Dependents (84)

Copyright 2014 - 2016 © taobao.org |