forked from duckduckgo/iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Fastfile
219 lines (189 loc) · 5.85 KB
/
Fastfile
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
default_platform :ios
before_all do
setup_ci if is_ci
end
#################################################
# Public lanes
#################################################
desc 'Fetches and updates certificates and provisioning profiles for App Store distribution'
lane :sync_signing do |options|
do_sync_signing(options)
end
desc 'Fetches and updates certificates and provisioning profiles for Ad-Hoc distribution'
lane :sync_signing_adhoc do |options|
do_sync_signing(options)
end
desc 'Makes Ad-Hoc build with a specified name in a given directory'
lane :adhoc do |options|
# Workaround for match + gym failing at build phase https://forums.swift.org/t/xcode-14-beta-code-signing-issues-when-spm-targets-include-resources/59685/32
if is_ci
configurations = [
{
targets: ["DuckDuckGo"],
profile_name: "match AdHoc com.duckduckgo.mobile.ios"
},
{
targets: ["ShareExtension"],
profile_name: "match AdHoc com.duckduckgo.mobile.ios.ShareExtension"
},
{
targets: ["OpenAction"],
profile_name: "match AdHoc com.duckduckgo.mobile.ios.OpenAction2"
},
{
targets: ["WidgetsExtension"],
profile_name: "match AdHoc com.duckduckgo.mobile.ios.Widgets"
},
{
targets: ["PacketTunnelProvider"],
profile_name: "match AdHoc com.duckduckgo.mobile.ios.NetworkExtension"
}
]
configurations.each do |config|
update_code_signing_settings(
use_automatic_signing: false,
build_configurations: ["Release"],
code_sign_identity: "iPhone Distribution",
**config
)
end
end
sync_signing_adhoc(options)
suffix = ""
if options[:suffix]
suffix = "#{options[:suffix]}-"
end
timestamp = Time.now.strftime("%Y-%m-%d-%H-%M")
output_name = "DuckDuckGo-#{suffix}#{timestamp}"
build_app(
output_directory: options[:output],
output_name: output_name,
export_method: "ad-hoc",
scheme: "DuckDuckGo",
export_options: "adhocExportOptions.plist",
derived_data_path: "DerivedData"
)
sh("echo output_name=#{output_name} >> $GITHUB_ENV")
Dir.chdir("..") do
sh("open", "#{options[:output]}") unless is_ci
end
end
desc 'Makes App Store release build and uploads it to App Store Connect'
lane :release_appstore do |options|
build_release(options)
deliver(common_deliver_arguments.merge(options))
begin
upload_metadata(options)
rescue => exception
UI.user_error! %{Failed to upload metadata: #{exception}
1. Your build has been successfully uploaded, it's only a problem with App Store metadata.
2. It's possible that there is a submission for another platform (macOS) in a non-editable state
(e.g. Pending Developer Release, Developer Rejected, Rejected or Metadata Rejected).
3. Before you retry, ensure that the pending macOS release is completed (Ready for Sale) or moved
back to "Prepare for Submission". If it can't be done at the moment and you can't wait, you'll need
to update metadata manually.
4. Use upload_metadata lane to only handle metadata (without building the release and uploading a build):
$ bundle exec fastlane upload_metadata
}
end
end
desc 'Updates App Store metadata'
lane :upload_metadata do |options|
deliver(common_deliver_arguments.merge(options).merge({
skip_binary_upload: true,
skip_metadata: false
}))
end
desc 'Makes App Store release build and uploads it to TestFlight'
lane :release_testflight do
build_release
upload_to_testflight(
api_key: get_api_key
)
end
desc 'Increment build number based on version in App Store Connect'
lane :increment_build_number_for_version do |options|
increment_build_number({
build_number:
latest_testflight_build_number(
version: options[:version],
app_identifier: "com.duckduckgo.mobile.ios",
initial_build_number: -1,
username: get_username(options)) + 1,
skip_info_plist: "true"
})
end
desc 'Setup Maestro e2e tests'
lane :setup_e2e_tests do |options|
shared_folder = 'shared'
e2e_test_folders = [
'release_tests',
'privacy_tests',
'ad_click_detection_flow_tests'
]
e2e_test_folders.each { | test_folder | FileUtils.copy_entry "../.maestro/#{shared_folder}", "../.maestro/#{test_folder}/#{shared_folder}" }
end
#################################################
# Private lanes
#################################################
private_lane :build_release do |options|
sync_signing(options)
build_app(
export_method: "app-store",
scheme: "DuckDuckGo",
export_options: "appStoreExportOptions.plist",
derived_data_path: "DerivedData"
)
end
private_lane :get_api_key do
has_api_key = [
"APPLE_API_KEY_ID",
"APPLE_API_KEY_ISSUER",
"APPLE_API_KEY_BASE64"
].map {|x| ENV.has_key? x}.reduce(&:&)
if has_api_key
app_store_connect_api_key(
key_id: ENV["APPLE_API_KEY_ID"],
issuer_id: ENV["APPLE_API_KEY_ISSUER"],
key_content: ENV["APPLE_API_KEY_BASE64"],
is_key_content_base64: true
)
else
nil
end
end
private_lane :get_username do |options|
if options[:username]
options[:username]
elsif is_ci
nil # don't make assumptions in CI
else
git_user_email = Action.sh("git", "config", "user.email").chomp
if git_user_email.end_with? "@duckduckgo.com"
git_user_email
end
end
end
private_lane :do_sync_signing do |options|
is_adhoc = lane_context[SharedValues::LANE_NAME].include?("adhoc")
sync_code_signing(
api_key: get_api_key,
username: get_username(options),
readonly: is_ci && !is_adhoc
)
end
def common_deliver_arguments
{
api_key: get_api_key,
submit_for_review: false,
automatic_release: false,
phased_release: true,
force: true,
skip_screenshots: true,
skip_metadata: true,
precheck_include_in_app_purchases: false,
submission_information: {
add_id_info_uses_idfa: false
}
}
end