-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRakefile.rb
51 lines (46 loc) · 1.51 KB
/
Rakefile.rb
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
require 'bundler'
Bundler::GemHelper.install_tasks
require 'rspec/core/rake_task';
RSpec::Core::RakeTask.new(:spec)
# Requires Bundler and adds the
#build, install and release
#Rake tasks by way of calling Bundler::GemHelper.install_tasks.
#The build task will build the current version of the gem and
#store it under the pkg folder, the install task will build
#and install the gem to our system (just like it would do if we
#gem install'd it) and release will push the gem to Rubygems for
#consumption by the public.
task :verify do
changed_files = `git diff --cached --name-only`.split("\n") + `git diff --name-only`.split("\n")
if !(changed_files == ['Rakefile.rb'] or changed_files.empty?)
raise "Repository contains uncommitted changes; either commit or stash."
end
end
desc 'Tag the repository in git with gem version number'
task :tag => :verify do
v = SemVer.find
Rake::Task["build"].invoke
if `git tag`.split("\n").include?("#{v.to_s}")
raise "Version #{v.to_s} has already been released! You cannot release it twice."
end
puts 'adding'
`git add Rakefile.rb`
puts 'committing'
`git commit -m "Released version #{v.to_s}"`
puts 'tagging'
`git tag #{v.to_s}`
puts 'locally installing'
Rake::Task["install"].invoke
end
desc "push data and tags"
task :push => :verify do
puts 'pushing tags'
`git push --tags`
puts 'pushing'
`git push`
end
desc "run specs, tag, push and release (to rubygems)"
task :all => [:verify] do
Rake::Task["spec"].invoke
Rake::Task["release"].invoke
end