forked from hodlwallet/hodl-wallet-ios
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bumpVersion.rb
32 lines (28 loc) · 1.21 KB
/
bumpVersion.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
# dependencies: gem install xcodeproj
#
# invocation: ruby bumpVersion.rb
#
# This will increment the CFBundleVersion of all of the required targets by one
#
require 'xcodeproj'
project_path = './dogecwallet.xcodeproj'
project = Xcodeproj::Project.open(project_path)
desiredTargets = ['dogecwallet', 'dogecwallet WatchKit Extension', 'dogecwallet WatchKit App', 'TodayExtension', 'NotificationServiceExtension', 'MessagesExtension']
targets = project.native_targets.select do |target|
desiredTargets.include? target.name
end
currentVersion = nil
currentShortVersion = nil
targets.each do |target|
info_plist_path = target.build_configurations.first.build_settings["INFOPLIST_FILE"]
plist = Xcodeproj::Plist.read_from_path(info_plist_path)
if currentVersion == nil
currentVersion = plist['CFBundleVersion']
end
if currentShortVersion == nil
currentShortVersion = plist['CFBundleShortVersionString']
end
plist['CFBundleVersion'] = (currentVersion.to_i + 1).to_s
plist['CFBundleShortVersionString'] = currentShortVersion.split('.').first(currentShortVersion.split('.').count - 1).join('.') + '.' + (currentShortVersion.split('.').last.to_i + 1).to_s
Xcodeproj::Plist.write_to_path(plist, info_plist_path)
end