Skip to content

Repository files navigation

Version Manager

Build StatusCode ClimateGem VersionDependency Status

Automatically manage version updates and tagging. The new version will be written to your version file, history file and as a tagged git commit.

Dependencies

  • Ruby >= 2.2
  • Rake

Installation

# In Gemfilegroup:developmentdogem"version_manager"end# In a Rake configuration filerequire"version_manager/rake_task"VersionManager::RakeTask.new(:release)do |config| # Argument is the namespace for tasksconfig.version_file="lib/version.rb"# Path to your version fileconfig.version_constant="VERSION"# Version constant including namespacesconfig.history_file="history.rdoc"# History file to be updatedconfig.tag_format="v%s"# %s will be replaced with the new version as tag namesconfig.logger=Logger.new# Replace the logger to turn off / modify stdout loggingend

Usage


bundle exec rake release:patch # Patch release eg 1.2.3 => 1.2.4
bundle exec rake release:minor # Minor release eg 1.2.3 => 1.3.0
bundle exec rake release:major # Major release eg 1.2.3 => 2.0.0

Configuration

config.version_file

The file which will be passed to load in order to load your current version number. It should be an absoltue file path or relative to your project's root

config.version_constant

The constant which will be loaded as the current version. For example, if your version number is in a module called MyModule as the constant MY_VERSION, the version_constant would be "MyModule::MY_VERSION" (as a string)

config.history_file

Path to your history file. Currently only supports rdoc format.

config.tag_format

The format git tags will be given after version has been updated. %s will be replaced with the version number

config.logger

The logger to use when printing info messages. By default this just logs the messages with no formatting to STDOUT. If you want to suppress logging you can just use Logger.new "/dev/null"

Example

Here is an example of what happens when you release a new version.

Given a version file lib/my_gem/version.rb which looks like this:

moduleMyGemVERSION="1.2.3"end

And a file history.rdoc which looks like this:

* Some important work
* Some bug fixes

And a rake task tasks/release.rake loaded by your Rakefile which looks like this:

require"version_manager/rake_task"VersionManager::RakeTask.newdo |config|
config.version_file="lib/my_gem/version.rb"config.version_constant="MyGem::VERSION"end

You can create a new release by using one of the following command:

bundle exec rake release:major
bundle exec rake release:minor
bundle exec rake release:patch

When you do this 3 things will happen:

  • The version file will be rewritten to contain the new version
moduleMyGemVERSION="2.0.0"end
  • This history file will have a new line containing the new version and today's date
== v2.0.0 (19 January 2017)
* Some important work
* Some bug fixes
  • The history and version files are both commited and tagged in git

The only things left to do then is push your new tag and commit then deploy the new release

About

Version updates for Ruby projects the easy way

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages