-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFastfile
More file actions
159 lines (127 loc) · 4.33 KB
/
Copy pathFastfile
File metadata and controls
159 lines (127 loc) · 4.33 KB
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
XCODE_PROJ = "DevLog.xcodeproj"
APP_IDENTIFIER = "opfic.DevLog"
WIDGET_IDENTIFIER = "opfic.DevLog.DevLogWidget"
APP_IDENTIFIERS = [APP_IDENTIFIER, WIDGET_IDENTIFIER]
TARGET_NAME = "DevLog"
WIDGET_TARGET_NAME = "DevLogWidgetExtension"
TESTFLIGHT_BUILD_OUTPUT_DIRECTORY = File.expand_path("testflight_build", __dir__)
TESTFLIGHT_IPA_OUTPUT_PATH = File.join(TESTFLIGHT_BUILD_OUTPUT_DIRECTORY, "#{TARGET_NAME}.ipa")
default_platform(:ios)
platform :ios do
private_lane :fetch_latest_testflight_build_number do |options|
require "spaceship"
api_key = options[:api_key]
version_number = options[:version]
Spaceship::ConnectAPI.token = Spaceship::ConnectAPI::Token.create(**api_key)
app = Spaceship::ConnectAPI::App.find(APP_IDENTIFIER)
UI.user_error!("Could not find app for #{APP_IDENTIFIER}") if app.nil?
filter = {
"state" => "PROCESSING,FAILED,COMPLETE",
"cfBundleShortVersionString" => version_number,
"platform" => Spaceship::ConnectAPI::Platform.map("ios")
}
build = Spaceship::ConnectAPI.get_build_uploads(
app_id: app.id,
filter: filter,
sort: "-uploadedDate",
limit: 1
).first
next 0 if build.nil?
next build.cf_build_version.to_i
end
private_lane :asc_api_key do
app_store_connect_api_key(
key_id: ENV["ASC_KEY_ID"],
issuer_id: ENV["ASC_ISSUER_ID"],
key_filepath: ENV["ASC_KEY_PATH"],
in_house: false
)
end
private_lane :build_for_store do
if ENV["FASTLANE_XCODEBUILD_SETTINGS_TIMEOUT"].to_s.strip.empty?
ENV["FASTLANE_XCODEBUILD_SETTINGS_TIMEOUT"] = "30"
end
if ENV["FASTLANE_XCODEBUILD_SETTINGS_RETRIES"].to_s.strip.empty?
ENV["FASTLANE_XCODEBUILD_SETTINGS_RETRIES"] = "5"
end
api_key = asc_api_key
version_number = get_version_number(
xcodeproj: XCODE_PROJ,
target: TARGET_NAME
)
latest_testflight_build_number = fetch_latest_testflight_build_number(
api_key: api_key,
version: version_number
)
setup_ci if ENV["CI"]
increment_build_number(
xcodeproj: XCODE_PROJ,
build_number: latest_testflight_build_number + 1
)
match(
api_key: api_key,
type: "appstore",
app_identifier: APP_IDENTIFIERS,
readonly: ENV["CI"] == "true"
)
if ENV["CI"] == "true"
profile_mapping = lane_context[SharedValues::MATCH_PROVISIONING_PROFILE_MAPPING]
signing_targets = {
TARGET_NAME => APP_IDENTIFIER,
WIDGET_TARGET_NAME => WIDGET_IDENTIFIER
}
signing_targets.each do |target_name, app_identifier|
provisioning_profile_specifier = profile_mapping[app_identifier].to_s
UI.user_error!("Missing App Store provisioning profile mapping for #{app_identifier}") if provisioning_profile_specifier.empty?
update_code_signing_settings(
use_automatic_signing: false,
path: XCODE_PROJ,
sdk: "iphoneos*",
team_id: ENV["APP_STORE_TEAM_ID"],
targets: [target_name],
build_configurations: ["Release"],
code_sign_identity: "Apple Distribution",
profile_name: provisioning_profile_specifier
)
end
end
build_app(
project: XCODE_PROJ,
scheme: TARGET_NAME,
export_method: "app-store",
output_directory: TESTFLIGHT_BUILD_OUTPUT_DIRECTORY,
output_name: "#{TARGET_NAME}.ipa",
xcargs: "-skipPackagePluginValidation"
)
next api_key
end
lane :deploy_testflight do
build_for_store
upload_testflight_build
end
lane :testflight_build_only do
build_for_store
end
lane :sync_appstore_profiles do
api_key = asc_api_key
match(
api_key: api_key,
type: "appstore",
app_identifier: APP_IDENTIFIERS,
force: true,
readonly: false
)
end
lane :upload_testflight_build do
api_key = asc_api_key
# lane_context는 같은 fastlane 실행 내에서만 유지되므로, 별도 CI step에서는 고정 ipa 경로를 사용한다.
ipa_output_path = lane_context[SharedValues::IPA_OUTPUT_PATH].to_s
ipa_output_path = TESTFLIGHT_IPA_OUTPUT_PATH if ipa_output_path.empty?
UI.user_error!("Missing built ipa at #{ipa_output_path}") if !File.exist?(ipa_output_path)
upload_to_testflight(
api_key: api_key,
ipa: ipa_output_path,
skip_waiting_for_build_processing: true
)
end
end