Created
October 14, 2010 18:32
-
-
Save groupdock/626739 to your computer and use it in GitHub Desktop.
Rakefile to deploy a Sproutcore application
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
require 'rake/clean' | |
# Deploying stuff starts here | |
require 'net/ssh' | |
require 'net/scp' | |
# Change the following constants accordingly | |
USER = 'yourusername' #TODO: change accordingly | |
HOSTNAME = 'yourhostname.com' #TODO: change accordingly | |
APPLICATION = 'hello_sprouts' #TODO: change accordingly | |
PORT = '8090' #TODO: change accordingly | |
# end constants | |
REMOTE_DIR = "/home/#{USER}/www/#{APPLICATION}" | |
desc "Deploy the site" | |
task :deploy => :clean do | |
FileUtils.rmtree 'tmp' | |
puts "building sproutcore..." | |
status = system 'sc-build' | |
if status | |
deployid = `ls tmp/build/http\:/#{HOSTNAME}\:#{PORT}/#{APPLICATION}/en`.strip | |
puts "creating archive..." | |
system "cd tmp/build/http\:/#{HOSTNAME}\:#{PORT}/ && tar -cvpzf static.tar.gz #{APPLICATION}/ sproutcore/" | |
puts "uploading archive..." | |
Net::SCP.start(HOSTNAME, USER) do |scp| | |
scp.upload! "tmp/build/http:/#{HOSTNAME}:#{PORT}/static.tar.gz", REMOTE_DIR | |
end | |
puts "setting up server..." | |
Net::SSH.start(HOSTNAME, USER) do |ssh| | |
ssh.exec! "rm -rf ~/www/#{APPLICATION}/#{APPLICATION}" | |
ssh.exec! "rm -rf ~/www/#{APPLICATION}/sproutcore" | |
ssh.exec! "rm ~/www/#{APPLICATION}/index.html" | |
ssh.exec! "cd ~/www/#{APPLICATION}/ && tar xzvf static.tar.gz" | |
ssh.exec! "rm ~/www/#{APPLICATION}/static.tar.gz" | |
ssh.exec! "ln -s ~/www/#{APPLICATION}/#{APPLICATION}/en/#{deployid}/index.html ~/www/#{APPLICATION}/index.html" | |
end | |
puts "SUCCESS!" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment