Automatic version numbering with git and Dist::Zilla

I love Dist::Zilla (dzil) because it automates so many of the busy-work tasks of releasing a new CPAN distribution. With dzil, when I release a distribution, dzil checks the last git release tag, bumps it up using Version::Next and uses that as the new version number for the release. It’s beautifully lazy.

I originally wrote the BumpVersionFromGit plugin to do this, but thanks to Jerome Quelin, it has been re-released as the Git::NextVersion plugin as part of the Dist-Zilla-Plugin-Git distribution.

If you already use Git::Tag but set your version numbers by hand in your dist.ini, install the Git::NextVersion plugin and try it out:

- version = 1.23
+ [Git::NextVersion]

That’s it!

If you have no release tags yet, the default for the first release is 0.001. If you don’t like that, just change the default:

first_version = 0.01

You can also override the version from the command line with the “V” variable. This is handy for bumping the version up for a major release:

$ V=1.000 dzil release

If you already use BumpNextVersionFromGit, there will be no further fixes for it, so please switch over to Git::NextVersion.

For more on Dist::Zilla, check out the Choose Your Own Tutorial.