Skip to content

Instantly share code, notes, and snippets.

@LeipeLeon
Created April 28, 2010 07:59
Show Gist options
  • Save LeipeLeon/381852 to your computer and use it in GitHub Desktop.
Save LeipeLeon/381852 to your computer and use it in GitHub Desktop.
set(:branch) do
if :production == stage
branch = Capistrano::CLI.ui.ask("#{`git branch`}\n\nWhich branch do you want to deploy?: ")
raise "Error: The master branch cannot be deployed to production." if 'master' == branch
else
`git branch | grep ^* | sed s/\\*\\ //`.chomp # use current active branche
end
end
namespace :deploy do
after "deploy:restart", "deploy:git:push_deploy_tag"
before "deploy:cleanup", "deploy:git:cleanup_deploy_tag"
namespace :git do
desc "Place release tag into Git and push it to server."
task :push_deploy_tag do
user = `git config --get user.name`
email = `git config --get user.email`
puts `git tag #{rails_env}_#{release_name} #{revision} -m "Deployed by #{user} <#{email}>"`
puts `git push --tags`
end
desc "Place release tag into Git and push it to server."
task :cleanup_deploy_tag do
count = fetch(:keep_releases, 5).to_i
if count >= releases.length
logger.important "no old release tags to clean up"
else
logger.info "keeping #{count} of #{releases.length} release tags"
tags = (releases - releases.last(count)).map { |release| "#{rails_env}_#{release}" }
tags.each do |tag|
`git tag -d #{tag}`
`git push origin :refs/tags/#{tag}`
end
end
end
end
end
for i in `ls -d *`
do rev=`cat $i/REVISION`
echo "git tag production_$i $rev"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment