-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
64 lines (48 loc) · 1.36 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
require 'bundler'
Bundler.setup
Bundler::GemHelper.install_tasks
require 'rspec/core/rake_task'
desc 'Run all specs'
RSpec::Core::RakeTask.new(:spec)
task default: :spec
task test: :spec
task :authors do
`make authors`
end
task :deploy, [:version] => [:spec, :authors] do |t, args|
current_version = Twilio::VERSION
if args.version.nil?
version = Twilio::VERSION
version_parts = version.split('.')
increment = version_parts.pop
increment_prefix = increment.split(/\d/)[0]
increment = increment[increment_prefix.length..-1] if increment_prefix
increment = increment.to_i + 1
increment = "#{increment_prefix}#{increment}" if increment_prefix
version = [*version_parts, increment].join('.')
else
version = args.version
end
puts("Deploying #{version}")
# Update version.rb
version_file = <<SRC
module Twilio
VERSION = '#{version}'
end
SRC
File.write('lib/twilio-ruby/version.rb', version_file)
# Update README.md
current_readme = File.read('README.md')
new_readme = current_readme.gsub(Regexp.new(current_version.gsub('.', '\.')), version)
File.write('README.md', new_readme)
# Make a git commit
`git commit -am "Bumping to version #{version}"`
# Do the gem deployment
`make gem`
# Push the branch back up
`git push`
# Tag the branch
`git tag #{version}`
# Push the tags
`git push --tags`
end