Version number bumping with grunt.

So I just got into using grunt (hey better late than never), and already I find myself stuck on one of the most simple aspects of managing a javaScript project, which is bumping the version number.

So I am having questions pop up in my mind like:

  • Do I bump the number before each push to my remote?
  • Do I bump the number when I start a new commit?
  • Do I just automate the process of bumping the patch number, and bump the minor, and major numbers manually?
  • Do I just want something that automates version number bumping, and nothing else?
  • Do I even want to automate this at all?
  • Am I putting to much thought into something that is very trivial?

I like to think that I have spent enough time re-inventing the wheel to earn the right to consider myself a half way decent programmer, as such if I really want to I could write my own script of course. However in the spirit of being more calculated about spending my time on things, I would like to start typing npm install a lot more if you know what I mean. So far I have found this when it comes to doing just that.

grunt-bump

1
$ npm install grunt-bump --save-dev

This allows for everything that comes to mind with getting the job done. In my Gruntfile I have it set up like this

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
grunt.initConfig({
bump : {
options : {
files : ['package.json'],
updateConfigs : [],
commit : false,
commitMessage : 'Release v%VERSION%',
commitFiles : ['package.json'],
createTag : false,
tagName : 'v%VERSION%',
tagMessage : 'Version %VERSION%',
push : false,
pushTo : 'upstream',
gitDescribeOptions : '--tags --always --abbrev=1 --dirty=-d',
globalReplace : false,
prereleaseName : false,
metadata : '',
regExp : false
}
}
});
grunt.loadNpmTasks('grunt-bump');

I have many things set to false, but for now when I do a

1
$ grunt bump

It will just bump the patch number, and it is clear that I can have it do a whole lot more than just that if need be. Off to a great start with grunt here moving on.