forked from sproutcore/abbot
/
Rakefile
265 lines (211 loc) · 6.88 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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
require File.expand_path("../lib/sproutcore/version", __FILE__)
desc "Information for setup"
task :default do
puts <<END
===================================================
**********************WARNING**********************
===================================================
It is not recommended that you install Abbot
directly from git. Unless you are hacking on Abbot
you should use the gem:
gem install sproutcore
===================================================
To get the SproutCore framework, run
git submodule init
git submodule update
To update the gem:
- Update VERSION.yml
- Run `rake release:prepare` on Mac OS X or Linux
This updates the CHANGELOGS for both framework and abbot,
updates version numbers and tags them. It also builds and
pushes gems. If you just want to see what it does, pass
PRETEND=1 to make no actual changes.
For best results you should have RVM with MRI Ruby and JRuby installed.
- Once you have verified your changes, run `rake release:deploy`.
- On Windows, update the repos and run `rake release:gems:deploy`
- To create installer packages, run `rake pkg` on Mac OS X and Windows
END
end
begin
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new
rescue LoadError
if Rake.application.options.show_tasks
puts "RSpec is not installed. Please install if you want to run tests."
end
end
begin
require 'packager/rake_task'
Packager::RakeTask.new(:pkg) do |t|
t.version = SproutCore::VERSION
t.domain = "sproutcore.com"
t.package_name = "SproutCore"
t.bin_files = Dir['bin/*'].map{|p| File.basename(p) }
t.resource_files = ["vendor", "VERSION.yml"]
end
rescue LoadError
if Rake.application.options.show_tasks
puts "`gem install packager` for packaging tasks"
end
end
### RELEASE TASKS ###
rvm_data = `rvm list` rescue nil
rvm_versions = rvm_data ? rvm_data.split("\n")[3..-1].map{|l| l[3..-1].split(" ")[0] } : []
rvm_mri = rvm_versions.select{|v| v =~ /^ruby-/ }[-1]
rvm_jruby = rvm_versions.select{|v| v =~ /^jruby-/ }[-1]
version = SproutCore::VERSION
namespace :release do
def pretend?
ENV['PRETEND']
end
namespace :framework do
task :chdir do
chdir File.expand_path('../lib/frameworks/sproutcore', __FILE__)
end
task :update do
branch = `git describe --contains --all HEAD`
puts "Checking out framework branch: #{branch}"
unless pretend?
Rake::Task["release:framework:chdir"].invoke
system "git checkout #{branch}"
system "git pull"
end
end
task :changelog => :chdir do
last_tag = `git describe --tags --abbrev=0`.strip
puts "Getting Changes since #{last_tag}"
cmd = "git log #{last_tag}..HEAD --format='* %s'"
puts cmd
changes = `#{cmd}`
output = "#{version}\n#{'-'*version.length}\n#{changes}\n"
unless pretend?
File.open('CHANGELOG.md', 'r+') do |file|
current = file.readlines
current.insert(3, output)
file.pos = 0;
file.puts current
end
else
puts output.split("\n").map!{|s| " #{s}"}.join("\n")
end
end
task :update_references => :chdir do
puts "Updating version references to #{version}"
cmd = "sed -i '' \"s/@version .*/@version #{version}/\" frameworks/runtime/core.js"
pretend? ? puts(cmd) : system(cmd)
cmd = "sed -i '' \"s/SC.VERSION = .*/SC.VERSION = '#{version}';/\" frameworks/runtime/core.js"
pretend? ? puts(cmd) : system(cmd)
end
task :commit => :chdir do
puts "Commiting Version Bump"
unless pretend?
system "git reset"
system "git add CHANGELOG.md frameworks/runtime/core.js"
system "git commit -m 'Version bump - #{version}'"
end
end
task :tag => :chdir do
puts "Tagging REL-#{version}"
system "git tag REL-#{version}" unless pretend?
end
task :push => :chdir do
puts "Pushing Repo"
unless pretend?
print "Are you sure you want to push the framework repo to github? (y/N) "
res = STDIN.gets.chomp
if res == 'y'
system "git push"
system "git push --tags"
else
puts "Not Pushing"
end
end
end
task :prepare => [:update, :changelog, :update_references]
task :deploy => [:commit, :tag, :push]
end
namespace :abbot do
task :chdir do
chdir File.dirname(__FILE__)
end
task :update do
puts "Checking updating repo"
system "git pull" unless pretend?
end
task :changelog => :chdir do
last_tag = `git describe --tags --abbrev=0`.strip
puts "Getting Changes since #{last_tag}"
cmd = "git log #{last_tag}..HEAD --format='* %s'"
puts cmd
changes = `#{cmd}`
output = "*SproutCore #{version} (#{Time.now.strftime("%B %d, %Y")})*\n\n#{changes}\n"
unless pretend?
File.open('CHANGELOG', 'r+') do |file|
current = file.read
file.pos = 0;
file.puts output
file.puts current
end
else
puts output.split("\n").map!{|s| " #{s}"}.join("\n")
end
end
task :commit => :chdir do
puts "Commiting Version Bump"
unless pretend?
system "git reset"
system "git add CHANGELOG VERSION.yml lib/frameworks/sproutcore"
system "git commit -m 'Version bump - #{version}'"
end
end
task :tag => :chdir do
puts "Tagging REL-#{version}"
system "git tag REL-#{version}" unless pretend?
end
task :push => :chdir do
puts "Pushing Repo"
unless pretend?
print "Are you sure you want to push the abbot repo to github? (y/N) "
res = STDIN.gets.chomp
if res == 'y'
system "git push"
system "git push --tags"
else
puts "Not Pushing"
end
end
end
task :prepare => [:update, :changelog]
task :deploy => [:commit, :tag, :push]
end
namespace :gems do
task :build do
versions = [rvm_mri, rvm_jruby].compact
unless versions.empty?
puts "Building for #{versions.join(", ")}"
system "rvm #{versions.join(',')} exec gem build sproutcore.gemspec" unless pretend?
else
puts "Building for current version"
system "gem build sproutcore.gemspec" unless pretend?
end
end
task :push do
Dir["sproutcore-#{version}*.gem"].each do |g|
puts "Pushing #{g}"
unless pretend?
print "Are you sure you want to push the gem to RubyGems.org? (y/N) "
res = STDIN.gets.chomp
if res == 'y'
system "gem push #{g}"
else
puts "Not Pushing"
end
end
end
end
task :prepare => []
task :deploy => [:build, :push]
end
task :prepare => ["framework:prepare", "abbot:prepare", "gems:prepare"]
task :deploy => ["framework:deploy", "abbot:deploy", "gems:deploy"]
end