-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
75 lines (63 loc) · 1.69 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
# Load up rspec-specific tasks
require 'rspec/core/rake_task'
# Run specs by default
task :default => 'install'
# Do our rspec thang
desc "Run specs"
RSpec::Core::RakeTask.new(:spec)
# Find and return the name of our latest gem
def latest
latest = Dir['*.gem'].first
raise "Can't find gem file!" if latest.nil?
File.basename(latest)
end
def version
raise "Missing Version.txt file!" unless File.exist?('Version.txt')
File.read('Version.txt').strip
end
desc 'Build gem'
task :build => [:test] do
Dir['*.gem'].each {|p| File.unlink(p) }
spec = File.basename(Dir['*.gemspec'].first)
puts ""
puts "Building #{spec}"
puts "--------------------"
puts `gem build #{spec}`
end
desc 'Install (and rebuild) gem'
task :install => [:build] do
puts ""
puts "Installing #{latest}"
puts "--------------------"
puts `gem install #{latest} --no-rdoc --no-ri`
end
desc 'Test the gem'
task :test do
puts ""
puts "Testing gem"
puts "--------------------"
Rake::Task['spec'].invoke
puts "Specs passed!"
end
desc 'Deploy to rubygems.org'
task :deploy => [:ready, :build] do
puts ""
puts "Deploying #{latest}"
puts "--------------------"
# Tag it in the github repo
puts `git tag --force -am "tag v#{version}" v#{version}`
puts `git push --tags origin`
# Update it on rubygems.org
puts `gem push #{latest}`
# Update minor version automatically
new_version = version.gsub(/([0-9]+)$/) {|minor| minor.to_i + 1}
`echo #{new_version} > Version.txt`
end
desc 'Make sure we have all changes checked into the GitHub repo'
task :ready do
res = `git status --porcelain`
unless res.strip.empty?
puts "\nGit reports changes - not ready for deployment!\n\n"
exit
end
end