Versioneer
Dynamic project versioning (alpha/beta/rc) from commits since last Git Tag.
Versioneer determines a project's version from the latest source-control tag, then adjusts automatically by adding/bumping prereleases based on changes made since the last tagged release.
Integration tested on UNIX/macOS and Windows. Matrix testing for Ruby 1.8
— 2.3
Overview
Project versions update automatically based on VCS changes and where the code has been deployed. The table below depicts the default settings; the prerelease workflow is customizable through code or a project config file.
VCS State | Last Tag/Release | Development Ver. | Production Ver. |
---|---|---|---|
No changes since last tag | v0.1.0 |
0.1.0 Same as Tag
|
0.1.0 Same as Tag
|
Uncommitted changes | v0.1.0 | 0.2.alpha1 |
0.1.0 Same as Tag
|
First commit | v0.1.0 | 0.2.beta1 |
0.2.rc1 or 0.1.1
|
First commit + Changes | v0.1.0 | 0.2.alpha2 |
0.2.rc1 or 0.1.1
|
Second commit | v0.1.0 | 0.2.beta2 |
0.2.rc2 or 0.1.2
|
Tag previous commit | v0.2.0 | 0.2.0 |
0.2.0 |
Usage
- Available from Command-Line or Ruby
- Project-level configuration using a
.versioneer.yml
file - The Versioneer environment is selected from the following system variables:
- Any value other than "production" is assumed to be "development"
ENV['VERSIONEER_ENV'] || ENV['RAILS_ENV'] || ENV['RACK_ENV'] || ENV['ENV']
Command-Line
$ git tag -am 'Release' v0.1
$ versioneer print
0.1
...
$ git commit --allow-empty -m 'Some changes.'
$ versioneer status
DEVELOPMENT -> 0.2.beta1
PRODUCTION -> 0.2.rc1
...
$ versioneer --help
Ruby Project (Rails, Rack, RubyGem, etc.)
Generic installation, adapt as necessary. See the Versioneer Wiki for more.
- Add Versioneer to your Gemfile
gem 'versioneer', '~> 0.1'
...
$ bundle install
- Generate a config file
$ bundle exec versioneer init
...
Generating config
+ .versioneer.yml
- Modify your project's version variable
$ vim config/version.rb
require 'versioneer'
module MyApp
# Configure versioneer with the project's root path:
VERSION = Versioneer::Config.new(File.expand_path('../../', __FILE__)).to_s
end
Settings & Customization
Please refer to the Versioneer Wiki for full documentation.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/binarybabel/gem-versioneer.
License
The gem is available as open source under the terms of the MIT License.