Rails Versioning


Lately I’ve been working on a Rails project and since I’m coming from iOS and Android background I had a need in versioning of my Rails app “builds”.

By “builds” I mean some grouped changes and commits that change the app enough that I can say that its version(major or minor) should go up.

Obviously in mobile apps such as iOS and Android projects you get this out of the box, in case of iOS xproj file contains 2 properties for version and build numbers, and in case of Android there is a AndroidManifest.xml file has versionCode and versionName properties in manifest tag.


Gem: versionator.

This was the easiest to use and quickest to install.

What it does:

This gem does 2 things:
1. creates VERSION file in the root of your project 2. pushes a git tag with the same name version name to your project’s origin master

How to use:


gem 'versionator’

bundle install


bundle exec rake versionator:patch to bump a patch version.
Example: from v1.1.1 to v1.1.2

bundle exec rake versionator:minor to bump a minor version.
Example: from v1.1.1 to v1.2.0

bundle exec rake versionator:major to bump a major version.
Example: from v1.1.1 to v2.0.0


versionator executes several git commands when you trigger one of the above rake commands:
1. Bump the version locally based on the version in /your_app/VERSION

2. Write the new version to /your_app/VERSION

3. git checkout master

4. git pull

5. git tag new version

6. git commit (This will commit your new VERSION file)

7. git push (new tag and VERSION file)

Pretty straightforward. It doesn’t do much and shouldn’t cause any problems but in my case I had a custom after-commit git hook which triggers some ruby code that launches sandi_meter commands for code analysis. My after-commit script didn’t work for some reason(I’ll investigate someday and make a blog post).


Versionator is the easiest to use and fastest to install solution if you need to version your Rails app’s code and have github tags pushed automatically.

Alex Bush @alex v bush

comments powered by Disqus