forked from wordpress-mobile/WordPress-iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate-build-and-upload-to-hockey-app.rb
executable file
·68 lines (53 loc) · 2.09 KB
/
generate-build-and-upload-to-hockey-app.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env ruby
def check_dependencies
unless Gem::Specification::find_all_by_name("shenzhen").any?
print "This script requires the \'shenzhen\' gem. You can install it by running \'gem install shenzhen\'\n"
exit
end
end
def update_internal_version_plist
require 'plist'
internal_plist = Plist::parse_xml('./WordPress/WordPress-Internal-Info.plist')
base_version_number = internal_plist["CFBundleVersion"]
# Check if we need to add a .0 to the end(i.e. 4.2 -> 4.2.0)
base_version_number = "#{base_version_number}.0" if base_version_number =~ /^\d+\.\d+$/
version_number_with_date = "#{base_version_number}.#{Time.now.strftime("%Y%m%d")}"
internal_plist["CFBundleVersion"] = version_number_with_date
internal_plist["CFBundleShortVersionString"] = version_number_with_date
internal_plist.save_plist("./WordPress/WordPress-Internal-Info.plist")
end
def build_ipa
update_internal_version_plist
print "Generating WordPress-Internal Archive\n"
Kernel.system('ipa build -w WordPress.xcworkspace/ -s "WordPress Internal" -c Release-Internal')
end
def get_hockey_app_api_token
unless File.exist?(".hockey_app_credentials")
print ".hockey_app_credentials must exist for this script to work properly\n"
exit
end
hockey_app_api_token = nil
File.open(".hockey_app_credentials") do |f|
f.each_line do |l|
(k,v) = l.split("=")
if k.downcase == "hockey_app_token"
hockey_app_api_token = v.chomp
end
end
end
if hockey_app_api_token.nil?
print ".hockey_app_credentials didn't have a value for HOCKEY_APP_TOKEN\n"
exit
end
hockey_app_api_token
end
def upload_ipa_to_hockey_app(hockey_app_api_token)
print "Uploading .ipa to HockeyApp\n"
Kernel.system("ipa distribute:hockeyapp -f WordPress.ipa --token #{hockey_app_api_token} --mandatory")
end
check_dependencies
build_ipa
upload_ipa_to_hockey_app(get_hockey_app_api_token)
File.delete("WordPress.app.dSYM.zip") if File.exist?("WordPress.app.dSYM.zip")
File.delete("WordPress.ipa") if File.exist?("WordPress.ipa")
Kernel.system("git checkout WordPress/WordPress-Internal-Info.plist")