forked from stenington/rubato
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrakefile
More file actions
54 lines (46 loc) · 1.33 KB
/
rakefile
File metadata and controls
54 lines (46 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
PROJ = "rubato"
TAR = "#{PROJ}.tar.gz"
DIR = "#{PROJ}/"
desc "runs index"
task :default => :index
desc "builds index.html"
task :index do
puts "creating index.html..."
text = File.read("src/#{PROJ}.html")
replace = text.gsub(/\.\.\/src/, "src")
File.open("./index.html", "w") {|file| file.puts replace}
puts "done"
end
desc "tar up the project"
task :tar do
excludes = %w( .git* *.tar.gz rakefile node README.md )
tarCmd = "env COPYFILE_DISABLE=true tar -C .." + excludes.map{|ex| " --exclude=" + ex}.to_s + " -czvf #{TAR} #{DIR}"
puts "tarring with: " + tarCmd
system(tarCmd)
end
desc "build index and tar it up"
task :all => [:clean, :index, :tar]
desc "clean up"
task :clean do
FileUtils.rm_f %Q( index.html #{TAR} ), :verbose => true
end
require 'yaml'
server = YAML::load(File.open('server.yml'))
HOST = server['HOST']
USER = server['USER']
REMOTE_DIR = server['REMOTE_DIR']
desc "deploy to #{HOST}"
task :deploy do
require 'net/ssh'
require 'net/scp'
Net::SSH.start(HOST, USER) do |ssh|
puts "scp #{TAR} -> #{REMOTE_DIR}"
ssh.scp.upload! "./#{TAR}", "#{REMOTE_DIR}#{TAR}" do |ch, name, sent, total|
puts " #{name}: #{sent} sent of #{total}"
end
puts "unpacking..."
ssh.exec!("tar -xzvf #{REMOTE_DIR}#{TAR} -C #{REMOTE_DIR} -m").each_line do |line|
puts " #{line}"
end
end
end