Skip to content

Instantly share code, notes, and snippets.

@foca
Created June 20, 2011 19:29
Show Gist options
  • Save foca/1036366 to your computer and use it in GitHub Desktop.
Save foca/1036366 to your computer and use it in GitHub Desktop.
Automatically create a tag of your repository when you deploy
namespace :git do
desc "Create a git tag of the current release"
task :tag_release do
ref = `git ls-remote #{repository} #{branch} | awk '{print $1}'`.chomp
# ISO representation of the current time
time = Time.now.utc.to_datetime.to_s
time.gsub! /-|:/, ""
time.gsub! /\+\d+$/, "Z"
command = "git tag #{branch}-#{time} #{ref} && git push origin --tags"
puts(command)
system(command)
end
end
after "deploy", "git:tag_release"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment