Using Autotagger

kmayer edited this page Mar 25, 2012 · 10 revisions

There are several best practices that can benefit from automation:

  • Continuous Integration (CI)
  • Staged deploys (i.e. Only deploy to staging when CI is green, only deploy to production after deploying to staging, first)
  • Labeling each release

HerokuSan and AutoTagger can help, and it's super easy.

Builds will be deployed in the following sequence:

  1. ci passes, creates ci tag from HEAD
  2. deploy latest ci tag to staging
  3. deploy latest staging tag to production

Update your CI build script

Add the following to your ci build script, this will create a tag if the build is successful. You should replace spec:all with whatever the build target is in your environment.

rake spec:all autotag:create[ci]

Update your heroku.yml configuration

Mix the following into your heroku.yml file:

  tag: ci/*
  tag: staging/*

Mix this into your heroku.rake file

STAGES = %w[ci staging production]

def create_and_push(stage)
  auto_tag = STAGES, stage: stage, verbose: true, push_refs: false, refs_to_keep: 100)
  tag = auto_tag.create_ref(auto_tag.last_ref_from_previous_stage.try(:sha))
  sh "git push origin #{}"

task :before_deploy do
  sh "git fetch --tags"

task :after_deploy do
  each_heroku_app do |stage|

namespace :autotag do
  desc "Create an autotag for stage, default: #{STAGES.first}"
  task :create, :stage do |t, args|
    create_and_push(args[:stage] || STAGES.first)
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.