-
Notifications
You must be signed in to change notification settings - Fork 4
/
deploy
executable file
·64 lines (45 loc) · 1.23 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
61
#!/usr/bin/env ruby
def execute(cmd)
puts "\n***************************************************************************\n"
puts "$ #{cmd}"
system(cmd)
end
def version_file_path
'./lib/tml/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 tml-#{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 tml.gemspec')
execute("gem install tml-#{version}.gem --no-ri --no-rdoc")
if ARGV.include?('release')
execute("git tag #{version}")
execute('git push --tags')
execute("gem push tml-#{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