After sticking to simple Html and Css for the longest time, I'm finally diving into JavaScript for a new project where I want to automate versioning. I've been following the SemVer Guidelines and my projects are currently versioned as
"version": "0.32.0"
and
## v0.31.0 (Jan 1, 2017)
The issue now is that I have no clue on how to automate this process. Using grunt, here's what I have so far:
module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
replace: {
version: {
src: [
'package.json',
'bower.json'
],
overwrite: true,
replacements: [{
from: 'oldver' ),
to: 'newver' )
}]
}
}
});
grunt.loadNpmTasks('grunt-text-replace');
grunt.loadNpmTasks('grunt-stamp');
grunt.registerTask('version', ['replace:version']);
grunt.registerTask('label', ['stamp'])
};
My goal is for grunt to read package.json with the current version:
"version": "0.32.0",
and then increment it by 1, resulting in:
"version": "0.33.0",
In addition, I also want the flexibility to update the X, Y, or Z individually. Moreover, if it's vX.Y.Z-alpha.X.Y.Z, I would like to be able to modify those parts separately as well.