Automatically tagging releases with capistrano
Even though Capistrano “tags” each release by creating a new folder on the production server(s), it might be interesting to have a historical perspective in your repository anyway.
This makes it easier to know exactly what went up for a release.
I would like to share the following Capistrano recipe for your pleasure:
config/deploy.rb
require 'uri'
task :after_deploy do
source = repository
dest = URI.parse(repository).merge("../releases/#{File.basename(release_path)}")
cmd = "svn copy --revision=#{revision} --quiet --message \"Auto tagging release #{release_path}\" #{source} #{dest}"
puts cmd
`#{cmd}`
end
First, we start by requiring uri, because Subversion does not like relative URLs.
Next, we find the location into which to tag the release, and finally, we just do it.
Simple, effective.
Enjoy !