forked from intersimone999/silos-apps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauto-bump-version.rb
40 lines (31 loc) · 981 Bytes
/
auto-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
require 'json'
FORCE = ARGV.delete("-f")
APPS = ARGV
def bump(appname)
info_file = "#{appname}/info.json"
infos = JSON.parse(File.read(info_file))
previous_version = infos['version']
major, minor = previous_version.split(".")
minor = (minor.to_i + 1).to_s
infos['version'] = "#{major}.#{minor}"
save = false
if FORCE
save = true
else
puts "Bump #{appname} version (#{previous_version} -> #{infos['version']})? (y/N)"
save = STDIN.gets.chomp.downcase.start_with?('y')
end
if save
File.open(info_file, 'w') do |f|
f.puts(JSON.pretty_generate(infos))
end
puts "Updated #{appname} version (#{previous_version} -> #{infos['version']})"
else
puts "Skipped #{appname}"
end
end
apps = APPS
apps = Dir.glob("*").sort.select { |e| FileTest.directory?(e) && !e.start_with?("_") } if apps.size == 0
apps.each do |appname|
bump(appname)
end