-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Fastfile
309 lines (267 loc) · 7.39 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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
fastlane_version "2.158.0"
default_platform :ios
platform :ios do
### MATCH
desc "Fastlane Match AppStore"
lane :setup_match_appstore do
setup_circle_ci
match_appstore
end
desc "Fastlane Match Enterprise"
lane :setup_match_enterprise do
setup_circle_ci
match_enterprise
end
desc "Fastlane Match Development"
lane :setup_match_development do
setup_circle_ci
match_development
end
desc "Fastlane Match - App Store"
private_lane :match_appstore do
match(
app_identifier: ["com.kickstarter.kickstarter"],
type: "appstore",
git_url: "https://github.com/kickstarter/ios-certificates",
team_id: "48YBP49Y5N",
git_branch: "ksr",
username: ENV["ITUNES_CONNECT_ACCOUNT"]
)
end
desc "Fastlane Match - Development"
private_lane :match_development do
match(
app_identifier: [
"com.kickstarter.kickstarter.debug"
],
type: "development",
git_url: "https://github.com/kickstarter/ios-certificates",
team_id: "48YBP49Y5N",
git_branch: "ksr",
username: ENV["ITUNES_CONNECT_ACCOUNT"],
force_for_new_devices: true
)
end
desc "Fastlane Match - Enterprise"
private_lane :match_enterprise do
match(
app_identifier: [
"com.kickstarter.kickstarter.beta",
"com.kickstarter.kickstarter.kickalpha"
],
type: "enterprise",
git_url: "https://github.com/kickstarter/ios-certificates",
team_id: "5DAN4UM3NC",
git_branch: "ksr-enterprise",
username: ENV["ITUNES_CONNECT_ACCOUNT"],
force_for_new_devices: true
)
end
### BETA
lane :beta_match_gym_appcenter_s3 do
setup_match_enterprise
xcode_check
beta_gym
beta_appcenter
beta_s3
end
desc "Build Beta"
lane :beta_gym do
build_the_app(
output_name: "KickBeta",
export_method: "enterprise",
configuration: "AppCenter Beta"
)
end
desc "Upload Beta to AppCenter"
lane :beta_appcenter do
upload_appcenter(
app_name: "KickBeta",
ipa: "#{gym_dir}/KickBeta.ipa",
dsym: "#{gym_dir}/KickBeta.app.dSYM.zip"
)
slack(
slack_url: ENV["SLACK_WEBHOOK"],
message: slack_message(
"beta",
get_version_number(xcodeproj: "Kickstarter.xcodeproj", target: "Kickstarter-iOS"),
get_build_number(xcodeproj: "Kickstarter.xcodeproj"),
"AppCenter"
)
)
end
desc "Upload Beta to S3"
lane :beta_s3 do
File.write('.FASTLANE_RELEASE_NOTES.tmp', changelog)
sh "./beta-changelog.rb"
upload_s3(
ipa: "#{gym_dir}/KickBeta.ipa",
dsym: "#{gym_dir}/KickBeta.app.dSYM.zip"
)
sh "./beta-post-s3.rb"
end
### PRODUCTION
lane :itunes_match_gym_deliver do
setup_match_appstore
xcode_check
itunes_gym
itunes_deliver
end
desc "Build Production"
lane :itunes_gym do
build_the_app(
output_name: "Kickstarter",
export_method: "app-store",
configuration: "Release"
)
end
desc "Upload to the App Store"
lane :itunes_deliver do
deliver(
force: true,
api_key_path: "./Frameworks/native-secrets/ios/app-store-connnect-auth.json",
app_identifier: ENV["ITUNES_APP_IDENTIFIER"],
app: ENV["ITUNES_APP_ID"],
ipa: "#{gym_dir}/Kickstarter.ipa",
team_name: ENV["ITUNES_TEAM_NAME"],
skip_screenshots: true,
skip_metadata: true,
precheck_include_in_app_purchases: false
)
upload_symbols_to_crashlytics(
gsp_path: "./Frameworks/native-secrets/ios/Firebase-Production/GoogleService-Info.plist",
binary_path: "./bin/upload-symbols",
dsym_path: "#{gym_dir}/Kickstarter.app.dSYM.zip"
)
slack(
slack_url: ENV["SLACK_WEBHOOK"],
message: slack_message(
"app store",
get_version_number(xcodeproj: "Kickstarter.xcodeproj", target: "Kickstarter-iOS"),
get_build_number(xcodeproj: "Kickstarter.xcodeproj"),
"App Store Connect 🚀"
)
)
end
### ALPHA
lane :alpha_match_gym_appcenter do
setup_match_enterprise
xcode_check
alpha_gym
alpha_appcenter
end
desc "Build Alpha"
lane :alpha_gym do
build_the_app(
output_name: "KickAlpha",
export_method: "enterprise",
configuration: "AppCenter Alpha"
)
end
desc "Upload Alpha to AppCenter"
lane :alpha_appcenter do
notes = "Branch: #{git_branch}, Recent changes: #{changelog}"
.sub("alpha-dist-", "") # strip branch prefix and trailing hyphen
.sub("-#{last_git_commit[:commit_hash]}", "") # strip last hyphen and commit hash
upload_appcenter(
app_name: "KickAlpha",
ipa: "#{gym_dir}/KickAlpha.ipa",
dsym: "#{gym_dir}/KickAlpha.app.dSYM.zip",
notes: notes
)
slack(
slack_url: ENV["SLACK_WEBHOOK"],
message: slack_message(
"alpha",
get_version_number(xcodeproj: "Kickstarter.xcodeproj", target: "Kickstarter-iOS"),
get_build_number(xcodeproj: "Kickstarter.xcodeproj"),
"AppCenter"
)
)
end
### SHARED
desc "Download App Store dSYMs and upload to Crashlytics"
lane :refresh_dsyms do |options|
download_dsyms(
username: ENV["ITUNES_CONNECT_ACCOUNT"],
app_identifier: ENV["ITUNES_APP_IDENTIFIER"],
team_name: ENV["ITUNES_TEAM_NAME"],
version: "latest"
)
clean_build_artifacts
slack(
slack_url: ENV["SLACK_WEBHOOK"],
message: "Successfully refreshed dSYMs for the latest App Store version"
)
end
private_lane :xcode_check do
xcodes(version: "13.3.1", select_for_current_build_only: true)
end
private_lane :build_the_app do |options|
export_options = {}
unless options[:configuration].eql? "Release"
# Disable bitcode for enterprise builds
export_options = {
includeBitcode: false,
compileBitcode: false
}
end
gym(
output_name: options[:output_name],
export_method: options[:export_method],
scheme: "Kickstarter-iOS",
configuration: options[:configuration],
export_options: export_options
)
end
private_lane :upload_appcenter do |options|
notes = (options[:notes] || changelog)
appcenter_upload(
api_token: ENV["APPCENTER_API_TOKEN"],
owner_name: ENV["APPCENTER_OWNER_NAME"],
app_name: options[:app_name],
ipa: options[:ipa],
dsym: options[:dsym],
notify_testers: true,
release_notes: notes
)
end
### HELPERS
### Grabs the last commit message into a changelog
private_lane :changelog do
changelog_from_git_commits(
commits_count: 1,
date_format: "short"
)
end
desc "Commit history from a given tag"
lane :commit_history do |options|
changelog_from_git_commits(
between: [options[:tag], "main"],
pretty: "- %s",
date_format: "short",
match_lightweight_tag: false,
merge_commit_filtering: "exclude_merges"
)
end
private_lane :upload_s3 do |options|
aws_s3(
bucket: ENV['AWS_BUCKET'],
region: ENV['AWS_REGION'],
ipa: options[:ipa],
dsym: options[:dsym],
path: "{CFBundleVersion}/",
upload_metadata: true
)
end
def gym_dir
ENV["GYM_OUTPUT_DIRECTORY"] || "."
end
def slack_message(type, version_number, build_number, platform)
"[#{type.upcase}] uploaded v#{version_number} (#{build_number}) of the Kickstarter iOS app to #{platform}"
end
after_all do |lane|
end
error do |lane, exception|
end
end