-
Notifications
You must be signed in to change notification settings - Fork 76
/
deploy
executable file
·63 lines (45 loc) · 1.27 KB
/
deploy
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
#!/usr/bin/env ruby
def execute(cmd)
puts "\n***************************************************************************\n"
puts "$ #{cmd}"
system(cmd)
end
def version_file_path
'./lib/will_filter/version.rb'
end
def version_file
@version_file ||= File.read(version_file_path)
end
def version
@version ||= version_file.match(/VERSION\s*=\s*'([^']*)'/)[1]
end
def increment_version
parts = version.split('.')
parts[2] = (parts[2].to_i + 1).to_s
new_version = parts.join('.')
version_file.gsub!(version, new_version)
File.open(version_file_path, 'w') do |file|
file.write(version_file)
end
@version_file = nil
@version = nil
end
puts "\nBuilding will_filter-#{version}.gem..."
if ARGV.include?('release')
execute('git checkout master')
execute('git merge develop')
execute('git push')
end
execute('bundle exec rspec')
execute('gem build will_filter.gemspec')
execute("gem install will_filter-#{version}.gem --no-ri --no-rdoc")
if ARGV.include?('release')
execute("git tag #{version}")
execute('git push --tags')
execute("gem push will_filter-#{version}.gem")
execute('git checkout develop')
increment_version
execute("git add #{version_file_path}")
execute("git commit -m 'Updated version to #{version}'")
execute('git push')
end