Created
July 28, 2011 16:25
-
-
Save sinisterchipmunk/1111873 to your computer and use it in GitHub Desktop.
Cap script for deploying gems to a static gem server, see http://thoughtsincomputation.com/posts/hosting-gems-with-apache-and-capistrano
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set :deploy_to, "public_html" # the remote path where the gem index lives | |
set :build_command, "bundle exec rake build" # the command to build the gem locally | |
set :user, "rubygems" # the user to log in to the server with | |
# the rubygems server to deploy to | |
server "gems.example.com", :app | |
desc "Deploy the gem and rebuild the index" | |
task :deploy do | |
build | |
upload_gem | |
generate_index | |
end | |
desc "Build the gem locally" | |
task :build do | |
result = %x[#{build_command}] | |
exit 1 unless $?.success? | |
unless result =~ /built to (.*?)\e|$/ | |
puts "Could not match filename from output" | |
puts result | |
exit 2 | |
end | |
set :filename, $1.strip | |
end | |
desc "Upload the gem to the rubygems server" | |
task :upload_gem do | |
put File.read(filename), File.join(deploy_to, "gems", File.basename(filename)) | |
end | |
desc "Rebuild the gem index on the rubygems server" | |
task :generate_index do | |
run "cd #{deploy_to} && gem generate_index -d ." | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment