Update the version, date, and other properties in JSON files while preserving the original indentation style.
date, and other properties in your JSON files.
The properties are updated only when already present in the original JSON file. Plugin also detects and preserves the original indentation style.
Note: if you want to create tag, commit, or push to a git repository in addition to bumping version, please consider grunt-bump.
Upholds the Semantic Versioning Specification.
Use npm to install and save the plugin into
npm install grunt-bumpup --save-dev
By default, the patch version is bumped.
You can specify a different release type bump in 1st argument:
And the build meta suffix in 2nd argument:
Available release types are:
x.0.0part of a version string.
0.x.0part of a version string.
0.0.xpart of a version string. If a prerelease exists, will only remove the prerelease number.
x.0.0part of a version strring and append a prerelease version of 0
0.x.xpart of a version strring and append a prerelease version of 0
0.0.xpart of a version strring and append a prerelease version of 0
0.0.0-xpart of a version string. If no prerelease exists, will also bump the patch
Full possible version format:
The prerelease part is appended only in prerelease bump type, and removed when present in major, minor, or patch bumps.
buildmeta suffix has to be passed manually:
You can also ignore everything above and pass a valid semantic version directly:
In your project's Gruntfile, add a section named
bumpup to the data object passed into
grunt.initConfig(). This is a
simple task, and does not conform to multi task options & files input types! All available configuration styles are
This is the most verbose form of the configuration:
Default options and one JSON file:
Default options, and multiple JSON files:
Custom options and setters:
Map of grunt config property names that should be updated after bumping.
Usage: If you have a
pkg convenience property from
package.json, and you bump up something inside it, you need to
tell that to grunt so the next tasks in queue can use the updated data.
Example: Tell bumpup to update the
pkg config property when bumping the
Whether to normalize all JSON files to have the same version. The version that is than bumped up and saved into all files is taken from the first file passed into the files array.
Whether to add a newline at the end when writing a JSON file.
YYYY-MM-DD HH:mm:ss Z
Following is the list of valid moment.js ISO-8601 (computer and human readable) date formats.
YYYY-MM-DDYYYY-MM-DDTHHYYYY-MM-DD HHYYYY-MM-DDTHH:mmYYYY-MM-DD HH:mmYYYY-MM-DDTHH:mm:ssYYYY-MM-DD HH:mm:ssYYYY-MM-DDTHH:mm:ss.SSSYYYY-MM-DD HH:mm:ss.SSSYYYY-MM-DDTHH:mm:ss ZYYYY-MM-DD HH:mm:ss Z
The dates are set in the UTC timezone, so including the Z token is recommended.
You can define your own property setters by passing them as functions into
setters object. For example, this will
timestamp property inside
You can also override the default setters for
date properties if you want some more control, or
other than default behavior.
All setters receive the same 4 arguments:
prerelease, or a valid semantic version.
Example showcasing simplified
Each setter has to return the new property value, or when something went wrong,
grunt.fail.warn() an error and return
Example "release" task alias that handles everything needed to build a new project release:
// Task configurationsgrunt;// Loading the pluginsgrunt;grunt;grunt;grunt;// Alias task for releasegrunt;// Alias task for release with buildmeta suffix supportgrunt;
And now you can call it from CLI like this:
grunt release // Default patch releasegrunt release:minor // Minor releasegrunt release:minor:1458 // Minor release with buildtype suffixgrunt release:build:1459 // Only build suffix will be modified