-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
44 lines (34 loc) · 1.15 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
require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
task :default => :spec
desc "Upload to rubygems"
task :upload => :build do
# Check if tag with v#{ResearchSiteApiClient::VERSION} version exists, if so, return with error
if tag_exists?(current_tag_name)
puts "Tag exists, did you run rake increase_revision_number after merging with master?"
exit 1
end
create_tag(current_tag_name)
Rake::Task[:release].invoke
end
desc "Increase the revision number"
task :increase_revision_number do
version_file = "lib/restful_resource/version.rb"
file_content = File.read(version_file)
rule = /(\d+\.\d+\.)(\d+)/
new_revision_number = rule.match(file_content)[2].to_i + 1
new_file_content = file_content.sub(rule, '\1' + new_revision_number.to_s)
File.open(version_file, 'w') { |file| file.write(new_file_content) }
end
def tag_exists?(tag_name)
result = `git tag | grep #{tag_name}`.strip
result == tag_name
end
def create_tag(tag_name)
sh "git tag -a #{tag_name} -m \"Released version #{tag_name}\""
sh "git push origin #{tag_name}"
end
def current_tag_name
"v#{RestfulResource::VERSION}"
end