forked from luximetr/AnyFormatKitSwiftUI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_version.rb
56 lines (33 loc) · 1.3 KB
/
update_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
43
44
45
46
47
48
49
50
51
52
53
if ARGV.empty?
print("❌ syntax had to be 'ruby update_version.rb version\n'")
exit
end
$new_version = ARGV[0]
def update_version(filePath, line_start, line_end)
file_data = File.open(filePath).readlines.map(&:chomp)
File.open(filePath, "w") { |file|
file_data.each { |line|
edited_line = line
if line.include? line_start
edited_line = "#{line_start}#{$new_version}#{line_end}"
end
file.write "#{edited_line}\n"
}
}
end
print("• updating podspec file\n")
podspec_version_line_start = " s.version = '"
podspec_version_line_end = "'"
update_version('AnyFormatKitSwiftUI.podspec', podspec_version_line_start, podspec_version_line_end)
print("• updating README file\n")
spm_package_line_start = ' .package(url: "https://github.com/luximetr/AnyFormatKitSwiftUI.git", .upToNextMajor(from: "'
spm_package_line_end = '"))'
pod_line_start = "pod 'AnyFormatKitSwiftUI', '~> "
pod_line_end = "'"
update_version('README.md', spm_package_line_start, spm_package_line_end)
update_version('README.md', pod_line_start, pod_line_end)
print("• updating xcodeproj file\n")
xproj_version_line_start = " MARKETING_VERSION = "
xproj_version_line_end = ";"
update_version('AnyFormatKitSwiftUI.xcodeproj/project.pbxproj', xproj_version_line_start, xproj_version_line_end)
print "✅ done\n"