-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
74 lines (63 loc) · 2.29 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
require 'yard'
require 'rake/testtask'
task :default => [:package]
task :clean do
FileUtils.rm_rf('./doc')
FileUtils.rm_rf('./.yardoc')
FileUtils.rm_rf('./pkg')
FileUtils.rm(Dir.glob('./rubycom-*.gem'))
end
task :bundle do
system('bundle install')
end
Rake::TestTask.new do |t|
t.libs << 'test'
t.test_files = FileList['test/*/*_test.rb']
t.verbose = true
end
YARD::Rake::YardocTask.new
task :package => [:clean, :bundle, :test, :yard] do
gem_specs = Dir.glob('**/*.gemspec')
gem_specs.each { |gem_spec|
system("gem build #{gem_spec}")
raise 'Error during build phase' if $?.exitstatus != 0
}
end
task :install => :package do
load "#{File.expand_path(File.dirname(__FILE__))}/lib/rubycom/version.rb"
system("gem install #{File.expand_path(File.dirname(__FILE__))}/rubycom-#{Rubycom::VERSION}.gem")
end
task :upgrade => :package do
system('gem uninstall rubycom -a')
load "#{File.expand_path(File.dirname(__FILE__))}/lib/rubycom/version.rb"
system("gem install #{File.expand_path(File.dirname(__FILE__))}/rubycom-#{Rubycom::VERSION}.gem")
end
task :version_set, [:version] do |_, args|
raise "Must provide a version.\n If you called 'rake version_set 1.2.3', try 'rake version_set[1.2.3]'" if args[:version].nil? || args[:version].empty?
version_file = <<-END.gsub(/^ {4}/, '')
module Rubycom
VERSION = "#{args[:version]}"
end
END
puts "Writing version file:\n #{version_file}"
File.open("#{File.expand_path(File.dirname(__FILE__))}/lib/rubycom/version.rb", 'w+') { |file|
file.write(version_file)
}
file_text = File.read("#{File.expand_path(File.dirname(__FILE__))}/lib/rubycom/version.rb")
raise 'Could not update version file' if file_text != version_file
end
task :release, [:version] => [:version_set, :package] do |_, args|
system('git clean -f')
system('git add .')
system("git commit -m\"Version to #{args[:version]}\"")
if $?.exitstatus == 0
system("git tag -a v#{args[:version]} -m\"Version #{args[:version]} Release\"")
if $?.exitstatus == 0
system('git push origin master --tags')
if $?.exitstatus == 0
load "#{File.expand_path(File.dirname(__FILE__))}/lib/rubycom/version.rb"
system("gem push #{File.expand_path(File.dirname(__FILE__))}/rubycom-#{Rubycom::VERSION}.gem")
end
end
end
end