version control with grunt

165 views Asked by At

Okay so I've avoided javascript for a long time now, not due to an inability to learn but due to my love for simple Html and Css. Now I'm delving into a project and want to automate versions. Following the SemVer Guidelines my projects are versioned as

"version": "0.32.0"

and

## v0.31.0 (Jan 1, 2017)

my issue is I have no idea how to automate this. I'm using grunt and have

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'])
};

I want grunt to read package.json and read

"version": "0.32.0",

and then I want it to add 1 to it, making

"version": "0.33.0",

of course i also want to have the ability for variables to be able to add to vX.Y.Z individually. And of course if it's vX.Y.Z-alpha.X.Y.Z I want to be able to change those individually as well.

1

There are 1 answers

0
TheGrimSilence On BEST ANSWER

For those of you who visit this question way later. grunt-bump handles it all as well as keeping in sync with semver guidelines.