robwierzbowski / grunt-build-control

Version control your built code.
MIT License
380 stars 36 forks source link

Semantic Versioning - Auto alpha/rc tag names #50

Closed micahgodbolt closed 9 years ago

micahgodbolt commented 9 years ago

We are trying to use build control in a semantic versioned distro. I'm hoping to be able to do something like what I posted below. I want to be able to run grunt buildcontrol:alpha and have a tag that is 2.1.0.alpha.4, or whatever is one number higher than the most recent alpha release matching that version. Of course it'd be nice to still be able to create 1.7.0.alpha.2 if needing to making changes on a different branch.

So logic would basically be, look at all tags for match. If no match then alpha/rc.1. If there is a match then match# +1.

    buildcontrol: {
      options: {
        ...
      },
      alpha: {
        options: {
          remote: 'git...',
          tag: pkg.version + '.alpha.' + number
        }
      },
      rc: {
        options: {
          remote: 'git...',
          tag: pkg.version + '.rc.' + number
        }
      },
      release: {
        options: {
          remote: 'git...',
          tag: pkg.version
        }
      },
    }
robwierzbowski commented 9 years ago

You can pass any variable into the grunt configuration — I think you'd want to write some js that reads the package.json and sets the version you want. This is sort of a tangential feature that would violate the "do one thing and do it well" principle. Build control is pretty big and complex as it is.

I'm pretty sure there are node packages out there that solve this part of the problem already. Can't think of any particular ones off the top of my head though.

micahgodbolt commented 9 years ago

Thanks @robwierzbowski ! I'll take a look into this. Just need to figure out how to parse the current tags and return the correct value.

robwierzbowski commented 9 years ago

var version = require('path/to/package.json').version will get you most of the way there. Just FYI require caches for the lifetime of the app (until grunt exits).

micahgodbolt commented 9 years ago

Yeah, i'm already able to grab the version just fine. Saw that in your demo text. Just trying to figure out a way to auto increment alpha/rc numbers without manually updating the package.json file. All of this will also change when we push this functionality up to Jenkins :) So it might handle the number increments all by itself.

Anyway, keep on rocking on.