Gulp: Bumping Versions

You may have noticed that Javascript build utilities all have their own JSON file for configuration – whether it be bower, npm, or whatever. There is always a JSON file and it is always versioned. So one of the things you tend to do is bump the version and check it in again.

That screams out for automation.

Someone else thought so too.

Let’s take a look at my bower.json file:

  "name": "WebApp",
  "version": "0.0.2",
  "private": true,
  "dependencies": {
    "app-router": "^2.6.1",
    "polymer": "^1.0.3",
    "webcomponentsjs": "^0.7.3"
  "overrides": {
    "polymer": {
      "main": "*.html"

Note the version string. The package.json file that npm uses and the project.json file that ASP.NET uses have this version field as well.

Big shout out to Steve Lacy for writing gulp-bump – a Gulp task handler that bumps the version number. Here is a recipe:

// Bump the version included in bower.json and package.json
gulp.task("bump-version", function () {
    return gulp.src(["./bower.json", "./package.json"])
        .pipe(plugins.bump({ type: "patch" }))

Now I have codified what needs to be changed, I just run gulp bump-version and all the files get updated.