Capistrano + Rails: Tagging production deploys

Just like Ruby Gems tag their version releases to the corresponding Git commit, it can be helpful to track production deploys within the commit history. This task does the tagging for you.

Capistrano 3

# lib/capistrano/tasks/deploy.rb
namespace :deploy do

  desc 'Tag the deployed revision'
  task :tag_revision do
    date =

    puts `git tag deploy-#{date} #{fetch :current_revision}`
    puts `git push --tags origin`

# config/deploy/production.rb
after 'deploy:finished', 'deploy:tag_revision'
Dominik Schöler over 3 years ago
This website uses short-lived cookies to improve usability.
Accept or learn more