Release script automates your release process for projects using git. Typically, releases involve a fixed number of steps to be executed in a given order. Most often these steps are always present:
- Update the version number and do a
git commit
- Do a
git tag
- Update the version number to the next development version and do a
git commit
- Push the new version to your package manager
- Do a
git push
Release Script will execute all these steps and can be customized to your needs with preconditions, version update hook and release hook.
Release Script takes an optional configuration object. Following properties are available:
push: boolean
whether to execute thegit push
command. Defaults totrue
.nextDevelopmentVersion: boolean | string
whether to update to the next development version after the release. If set totrue
and a release of version1.0.0
, the next development version will be1.0.0-0
. A string can used to specify the prerelease id (e.g. using'dev'
will result in1.0.0-dev.0
). Defaults totrue
.tag: boolean | string
whether to perform agit tag
. A string can be used to specify a prefix for the tag name (e.g. a prefix of'v'
will generate a git tagv1.0.0
). Defaults to'v'
.gitSign
Whether to sign git commits and tagspreconditions
Array of precondition hook function.versionHook
Array of version update hook function.releaseHook
Array of release hook function.
The release script can be customized by the following hooks
- Precondition: Checks that must be valid before performing a release.
- Version update hook: Update to the new version (e.g. change version field in package.json)
- Release hook: Perform the actual release (e.g. publish package to npm). This hook should not change any files, use the version update hook instead.
Every hook is a function which gets the current ReleaseContext as the only argument and should return a Promise, that resolves for a successfull execution and rejects for an error. Errors will cause release script to terminate without any special error handling or reverting changes. Therefore extra care must be taken by the user if release script terminates with an error.
- All precondition hooks
- All version update hook with the version to release
git commit
(only if previous version hook changed any files)git tag
- All release hooks
- All version update hooks with the next development version (optional)
git commit
(only if previous version hook changed any files)git push
The ReleaseContext
holds any information relevant to the current release. The following properties are available:
directory: string
The root directory of the git repositoryversion
An instance of theSemVer
class holding the current version numberconfig
the configuration object the release script was started with.git
An instance of theGit
class holding a reference to the current git repositoryisNextDevelopmentVersion: boolean
This will only betrue
for the version update hook with the next development version, otherwise it will befalse