forked from engineyard/engineyard
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRakefile
77 lines (65 loc) · 2.43 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
require 'spec/rake/spectask'
Spec::Rake::SpecTask.new(:spec) do |spec|
spec.libs << 'lib' << 'spec'
spec.spec_files = FileList['spec/**/*_spec.rb']
end
task :default => :spec
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'lib'))
require 'rake/rdoctask'
require File.expand_path("../lib/engineyard", __FILE__)
Rake::RDocTask.new do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = "engineyard #{EY::VERSION}"
rdoc.rdoc_files.include('README*')
rdoc.rdoc_files.include('lib/**/*.rb')
rdoc.rdoc_files.exclude('lib/vendor/**/*.rb')
end
def bump
require 'engineyard'
version_file = "module EY\n VERSION = '_VERSION_GOES_HERE_'\nend\n"
new_version = if EY::VERSION =~ /\.pre$/
EY::VERSION.gsub(/\.pre$/, '')
else
digits = EY::VERSION.scan(/(\d+)/).map { |x| x.first.to_i }
digits[-1] += 1
digits.join('.') + ".pre"
end
puts "New version is #{new_version}"
File.open('lib/engineyard/version.rb', 'w') do |f|
f.write version_file.gsub(/_VERSION_GOES_HERE_/, new_version)
end
new_version
end
def bump_to_latest_serverside
require 'engineyard'
serverside_version_file = "module EY\n ENGINEYARD_SERVERSIDE_VERSION = ENV['ENGINEYARD_SERVERSIDE_VERSION'] || '_VERSION_GOES_HERE_'\nend\n"
new_version = `gem search -r engineyard-serverside`.grep(/^engineyard-serverside /).first.match(/\((.*?)\)/).captures.first
puts "Using engineyard-serverside version #{new_version}"
File.open('lib/engineyard/serverside_version.rb', 'w') do |f|
f.write serverside_version_file.gsub(/_VERSION_GOES_HERE_/, new_version)
end
new_version
end
desc "Bump version of this gem"
task :bump do
ver = bump
puts "New version is #{ver}"
end
desc "Release gem"
task :release do
new_version = bump
bump_to_latest_serverside
system("git add lib/engineyard/version.rb lib/engineyard/serverside_version.rb")
system("git commit -m 'Bump versions for release #{new_version}'")
system("git tag v#{new_version}")
system("gem build engineyard.gemspec")
load 'lib/engineyard/version.rb'
bump
system("git add lib/engineyard/version.rb")
system("git commit -m 'Add .pre for next release'")
puts '********************************************************************************'
puts
puts "Don't forget to `gem push` and `git push --tags`!"
puts
puts '********************************************************************************'
end