forked from etsy/deployinator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
98 lines (76 loc) · 2.02 KB
/
Rakefile
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# Stolen from github.com/defunkt/mustache
require 'rake/testtask'
#
# Helpers
#
def command?(command)
system("type #{command} &> /dev/null")
end
#
# Tests
#
task :default => :test
Rake::TestTask.new do |t|
t.libs << 'lib'
t.pattern = 'test/**/*_test.rb'
t.verbose = false
end
#
# Stacks
#
desc "Create a new deployinator stack. usage: STACK=my_blog rake new_stack"
task :new_stack do
require 'mustache/sinatra'
stack = ENV['STACK']
raise "You must supply a stack name (like STACK=foo rake new_stack)" unless stack
raise "Already exists" if File.exists?("./stacks/#{stack}.rb")
File.open("./stacks/#{stack}.rb", "w") do |f|
contents = <<-EOF
module Deployinator
module Stacks
module #{Mustache.classify(stack)}
def #{stack}_production_version
# %x{curl http://my-app.com/version.txt}
"cf44aab-20110729-230910-UTC"
end
def #{stack}_head_build
# the build version you're about to push
# %x{git ls-remote #\{your_git_repo_url\} HEAD | cut -c1-7}.chomp
"11666e3"
end
def #{stack}_production(options={})
log_and_stream "Fill in the #{stack}_production method in stacks/#{stack}.rb!<br>"
# log the deploy
log_and_shout :old_build => environments[0][:current_build].call, :build => environments[0][:next_build].call
end
end
end
end
EOF
f.print contents
end
File.open("./templates/#{stack}.mustache", "w") do |f|
f.print "{{< generic_single_push }}"
end
puts "Created #{stack}!\nEdit stacks/#{stack}.rb##{stack}_production to do your bidding"
end
#
# Documentation
# A github page at some point
#
desc "Publish to GitHub Pages"
task :pages => [ "man:build" ] do
Dir['man/*.html'].each do |f|
cp f, File.basename(f).sub('.html', '.newhtml')
end
`git commit -am 'generated manual'`
`git checkout site`
Dir['*.newhtml'].each do |f|
mv f, f.sub('.newhtml', '.html')
end
`git add .`
`git commit -m updated`
`git push site site:master`
`git checkout master`
puts :done
end