Generate a release for a project following semver using nodejs and gitflow
MIT License
Generate a release for a project following semver using nodejs and gitflow or git-stream
Current Version: 1.1.1
Requires NodeJS v4.0.0 or greater
You can either install generate-release
globally or for a single project
Globally
Install package
npm install -g generate-release
Navigate to your project and execute generate-release
Locally
cd your/project
npm install --save-dev generate-release
Then add the following to your package.json
file:
{
"scripts": {
"release": "generate-release"
}
}
Then you can run npm run-script release
in order to generate a release.
Important notes for gitflow OSX
Git-flow from nvie is broken on OSX, and generate-release
will not work. Please use the updated and actively
maintained version from petervanderdoes,
https://github.com/petervanderdoes/gitflow-avh. Please follow the
OSX Install Guide
This is the default process.
remote
remote
/develop into developremote
/masterfiles_to_version
pre_commit_commands
files_to_version
and files_to_commit
pre_commit_commands
post_commit_commands
remote
post_complete_commands
If any of the steps aside from the post_complete_commands
step fail, the entire release is canceled and everything
is reset.
All commands are run in either sh
or cmd.exe
. If sh
is available, even on windows, it will use that first.
CLI
run generate-release --help
to see this as well.
-p, --package FILE Path to package.json file. Default: ./package.json
-c, --current-version VERSION Current Version. Default: read from package.json
-v, --next-version VERSION Next Version. Default: automatically bumps
-t, --release-type TYPE Release Type: patch, minor, major. Ignored when next-version is given. Default: prompt, if next-version is undefined
-n, --no-confirm Do not ask for confirmation. Default: prompt for confirmation
-l, --skip-git-pull Do not pull from origin and rebase master and dev. Default: Do pull
-s, --skip-git-push Do not push to origin when complete. Default: Do push
-f, --skip-git-flow-finish, Do not finish git-flow release. Default: Do finish
--skip-finish
-d, --release-file FILE Path to your .release.json file. Default: ./.release.json
-o, --remote REMOTE Change the remote. Default: origin
-q, --quiet Less output. Default: Do show output
-m, release-message [MESSAGE] Set a release message. If no message given, prompt for one. Will replace
"{version}" with the next version. Default: Release {version}
Release File
By default, the following options can be set in a .release.json
file. The following
is an example with all default options set.
{
"package_file_location": "./package.json",
"no_confirm": false,
"skip_git_pull": false,
"skip_git_push": false,
"skip_finish": false,
"release_message": true,
"remote": "origin",
"pre_commit_commands": [],
"post_commit_commands": [],
"post_complete_commands": [],
"files_to_commit": [],
"files_to_version": ["README.md"]
}
The files_to_commit
and files_to_version
use node-glob. See the
documentation located there on how to format those options.
If release_message
is true, then you will be prompted to write a release message via your editor of choice.
package.json
If you are using this for an NPM package, you can include all the above options in your package.json instead of a dedicated file.
Place all your configuration options in config : generateRelease
.
{
...
"config": {
"generateRelease": {
"no_confirm": false,
"remote": "origin"
}
},
...
}
Option Precedence
Precedence is determined in the following order:
If you wish to build assets, run test, and/or publish your project automatically when the
release is being generated you can use the example .release.json
file below. The
following assumptions are made:
build-assets
./build
npm test
commandnpm publish
command.release.json
{
"pre_commit_commands": [
"npm run-script build-assets"
],
"post_commit_commands": [
"npm test"
],
"post_complete_commands": [
"npm publish"
],
"files_to_commit": [
"./build/**/*"
]
}
It's quite simple to use this on a non NPM based repo. The only npm specific aspect baked into Generate Release is the
usage of the package.json file. In fact, you are able to use any json file which maintains a version property. If you
are working on a PHP project which uses Composer, the composer.json already has the required
property. Either call generate-release with -p composer.json
or set the package_file_location
property of your
.release.json
file.
If your project does not already contain a json file which maintains a version, you just use the .release.json
file! Just put a version property in the file and set package_file_location
to ".release.json".