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: booleanwhether to execute thegit pushcommand. Defaults totrue.nextDevelopmentVersion: boolean | stringwhether to update to the next development version after the release. If set totrueand 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 | stringwhether 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'.gitSignWhether to sign git commits and tagspreconditionsArray of precondition hook function.versionHookArray of version update hook function.releaseHookArray 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: stringThe root directory of the git repositoryversionAn instance of theSemVerclass holding the current version numberconfigthe configuration object the release script was started with.gitAn instance of theGitclass holding a reference to the current git repositoryisNextDevelopmentVersion: booleanThis will only betruefor the version update hook with the next development version, otherwise it will befalse