forked from emberjs/ember.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
160 lines (127 loc) · 4.18 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
require 'bundler/setup'
require 'ember-dev/tasks'
require './lib/ember/version'
require 'zlib'
require 'fileutils'
require 'pathname'
require 'json'
### RELEASE TASKS ###
namespace :release do
def pretend?
ENV['PRETEND']
end
task :gem do
sh "rakep"
sh 'gem build ember-source.gemspec'
sh "gem push ember-source-#{Ember::VERSION.gsub('-','.')}.gem"
end
namespace :starter_kit do
ember_output = "tmp/starter-kit/js/libs/ember-#{Ember::VERSION}.js"
task :pull => "tmp/starter-kit" do
cd("tmp/starter-kit") do
sh "git pull origin master"
end
end
task :clean => :pull do
cd("tmp/starter-kit") do
rm_rf Dir["js/libs/ember*.js"]
end
end
file "dist/ember.js" => :dist
file "dist/ember.min.js" => :dist
task "dist/starter-kit.#{Ember::VERSION}.zip" => ["tmp/starter-kit/index.html"] do
mkdir_p "dist"
cd("tmp") do
sh %{zip -r ../dist/starter-kit.#{Ember::VERSION}.zip starter-kit -x "starter-kit/.git/*"}
end
end
file ember_output => [:clean, "tmp/starter-kit", "dist/ember.js"] do
sh "cp dist/ember.js #{ember_output}"
end
file "tmp/starter-kit" do
mkdir_p "tmp"
cd("tmp") do
sh "git clone [email protected]:emberjs/starter-kit.git"
end
end
file "tmp/starter-kit/index.html" => [ember_output] do
index = File.read("tmp/starter-kit/index.html")
index.gsub! %r{<script src="js/libs/ember-\d\.\d.*</script>},
%{<script src="js/libs/ember-#{Ember::VERSION}.js"></script>}
open("tmp/starter-kit/index.html", "w") { |f| f.write index }
end
task :index => "tmp/starter-kit/index.html"
desc "Update starter-kit repo"
task :update => :index do
puts "Updating starter-kit repo"
unless pretend?
cd("tmp/starter-kit") do
sh "git add -A"
sh "git commit -m 'Updated to #{Ember::VERSION}'"
sh "git tag v#{Ember::VERSION}"
print "Are you sure you want to push the starter-kit repo to github? (y/N) "
res = STDIN.gets.chomp
if res == 'y'
sh "git push origin master"
sh "git push --tags"
else
puts "Not pushing"
end
end
end
end
desc "Build the Ember.js starter kit"
task :build => "dist/starter-kit.#{Ember::VERSION}.zip"
desc "Prepare starter-kit for release"
task :prepare => [:clean, :build]
desc "Release starter-kit"
task :deploy => [:build, :update]
end
namespace :website do
file "tmp/website" do
mkdir_p "tmp"
cd("tmp") do
sh "git clone https://github.com/emberjs/website.git"
end
end
task :pull => "tmp/website" do
cd("tmp/website") do
sh "git pull origin master"
end
end
task :about => [:pull, :dist] do
about = File.read("tmp/website/source/about.html.erb")
min_gz = Zlib::Deflate.deflate(File.read("dist/ember.min.js")).bytes.count / 1024
about.gsub!(/(\d+\.\d+\.\d+-rc(?:\.?\d+)?)/, Ember::VERSION)
about.gsub!(/min \+ gzip \d+kb/, "min + gzip #{min_gz}kb")
open("tmp/website/source/about.html.erb", "w") { |f| f.write about }
end
desc "Update website repo"
task :update => :about do
puts "Updating website repo"
unless pretend?
cd("tmp/website") do
sh "git add -A"
sh "git commit -m 'Updated to #{Ember::VERSION}'"
print "Are you sure you want to push the website repo to github? (y/N) "
res = STDIN.gets.chomp
if res == 'y'
sh "git push origin master"
sh "git push --tags"
else
puts "Not pushing"
end
end
puts "NOTE: You still need to run `rake deploy` from within the website repo."
end
end
desc "Prepare website for release"
task :prepare => [:about]
desc "Update website repo"
task :deploy => [:update]
end
desc "Prepare Ember for new release"
task :prepare => ['ember:clean', 'ember:release:prepare', 'starter_kit:prepare', 'website:prepare']
desc "Deploy a new Ember release"
task :deploy => ['ember:release:deploy', 'starter_kit:deploy', 'website:deploy']
end