No commit activity in last 3 years
No release in over 3 years
Rake tasks to manage application semantic version.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.16
~> 0.7.0
>= 0
~> 4.2
~> 12.3
~> 3.0
>= 3.4.2, ~> 3.4
~> 0.12
>= 0

Runtime

~> 1.3
 Project Readme

Build Status Code Climate Test Coverage Issue Count Inline docs Gem Version

AppVersionTasks

Rake tasks for application semantic version and release management. Inspired by:

Installation

$ gem install app_version_tasks

Configuration for a ruby gem

Add this gem and then bundle install:

Gem::Specification.new do |spec|
  spec.add_development_dependency 'app_version_tasks'
end

In the Rakefile, try this snippet and customize as required.

require 'app_version_tasks'
spec = Gem::Specification.find_by_name 'app_version_tasks'
load "#{spec.gem_dir}/lib/tasks/app_version_tasks.rake"
AppVersionTasks.configure do |config|
  config.application_name = 'GreatGem'
  config.version_file_path = File.join('lib', 'great_gem', 'version.rb')
end

Configuration for a rails application

Add this gem and bundle install:

gem 'app_version_tasks'

In the Rakefile, load and configure with this snippet:

require 'app_version_tasks'
spec = Gem::Specification.find_by_name 'app_version_tasks'
load "#{spec.gem_dir}/lib/tasks/app_version_tasks.rake"
AppVersionTasks.configure do |config|
  # the following settings are the defaults
  config.application_name = Rails.application.class.parent_name
  config.version_file_path = File.join(Rails.root, 'config', 'version.rb')
  config.git_working_directory = Rails.root.to_s
end

Each of the rake tasks that bump the semantic version will modify an application version file; by default, the template for that file looks like this:

# Rails.root/config/version.rb
module #{Rails.application.class.parent_name}
  class Application
    VERSION = '0.0.0'
  end
end

If the version file does not exist, it will be created automatically from that template. If it exists already, it is assumed that it contains a single quoted string matching the regex pattern: /'\d+.\d+.\d+'/

The default version_file_path is Rails.root/config/version.rb, but that can be configured (see above). When the default location is used, the version file can be included in the config/application.rb using:

# Rails.root/config/application.rb
require_relative 'version'

If a different version file is used and it does not contain the structure above, it might work with this gem. The code in this gem simply assumes the version file contains a semantic version surrounded by single quotes, e.g. 'x.y.z', where the single quotes around the version string are an important assumption.

Usage

rake -T should include these version tasks:

version:bump:major - bump and commit the major version (x in x.0.0)
                   - resets the minor and patch versions to zero
                   - does not push the local workspace to 'origin'
version:bump:minor - bump and commit the minor version (y in x.y.0)
                   - resets the patch version to zero
                   - does not push the local workspace to 'origin'
version:bump:patch - bump and commit the patch version (z in x.y.z)
                   - does not push the local workspace to 'origin'
version:current    - the current version
version:release    - tag and push the current version
                   - pushes to 'origin/{current_branch}'

Report the current version

bundle exec rake version:current

Bump and commit a patch version

# Example: 0.0.0 moves to 0.0.1
# Example: 1.1.1 moves to 1.1.2
bundle exec rake version:bump:patch

Bump and commit a minor version

# Example: 0.0.1 moves to 0.1.0
# Example: 1.1.2 moves to 1.2.0
bundle exec rake version:bump:minor

Bump and commit a major version

# Example: 0.1.0 moves to 1.0.0
# Example: 1.2.0 moves to 2.0.0
bundle exec rake version:bump:major

Tag and push the current version

# Example: tag 'v2.0.0' and push to origin
bundle exec rake version:release

Development

After checking out the repo, run ./bin/setup to install dependencies. Then, run rake to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/darrenleeweber/app_version_tasks