GemVersion

Automated version management for your Gem builds.

Resources

Install

  • sudo gem install gem_version

Use

  • require ‘gem_version’

Description

Never bother updating the version for your next gem build by hand. Configured in your Rakefile, gem_version automatically provides the next version and commits it to the repository.

Use

Require the library in your Rakefile:

require 'gem_version'

Use gem_version in your Gem Specification:

spec = Gem::Specification.new do |s|
  s.version = GemVersion.next_version
  ...
end

Increment and commit the gem version in your Gemspec rake task:

desc 'Generate a gemspec file.'
task :gemspec do
  File.open("#{spec.name}.gemspec", 'w') do |f|
    f.write spec.to_ruby
  end
  GemVersion.increment_version
  GemVersion.commit_and_push
end

Everytime you build your gem (this example uses Gemcutter):

rake gemspec
gem build your_gem_name.gemspec

GemVersion provides the next version for each build.

See my Rakefile for an example.

Bumping or resetting the next gem version

GemVersion creates a file named ‘next_gem_version’ in the root directory of your project which contains the ‘next’ gem version. Edit the version in this file to bump or reset the version for the next build.

GemVersion increments the last component of your version. If you need to bump from 0.1.x to 0.2.x, you’ll need to make the change in the file.

Dependencies

  • Git gem (>= 1.2.5)