-
Notifications
You must be signed in to change notification settings - Fork 1k
/
bump-version.rb
executable file
·42 lines (35 loc) · 1.04 KB
/
bump-version.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
#!/usr/bin/env ruby
# typed: true
# frozen_string_literal: true
unless %w(minor patch).include?(ARGV[0])
puts "usage: bin/bump-version.rb minor|patch"
exit 1
end
component = ARGV[0].to_sym
# Update version file
version_path = File.join(__dir__, "..", "common", "lib", "dependabot.rb")
version_contents = File.read(version_path)
version = version_contents.scan(/\d+.\d+.\d+/).first
segments = Gem::Version.new(version).segments
new_version =
case component
when :minor
[segments[0], segments[1] + 1, 0].join(".")
when :patch
[segments[0], segments[1], segments[2] + 1].join(".")
end
new_version_contents = version_contents.gsub(version, new_version)
File.write(version_path, new_version_contents)
# Bump the updater's Gemfile.lock with the new version
`cd updater/ && bundle lock`
unless $?.success?
puts "Failed to update `updater/Gemfile.lock`"
exit $?.exitstatus
end
# Bump the root's Gemfile.lock with the new version
`bundle lock`
unless $?.success?
puts "Failed to update `Gemfile.lock`"
exit $?.exitstatus
end
puts new_version