-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathFastfile
187 lines (164 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
# This file contains the fastlane.tools configuration
# You can find the documentation at https://docs.fastlane.tools
#
# For a list of all available actions, check out
#
# https://docs.fastlane.tools/actions
#
# For a list of all available plugins, check out
#
# https://docs.fastlane.tools/plugins/available-plugins
#
# Uncomment the line if you want fastlane to automatically update itself
# update_fastlane
# https://www.runway.team/blog/how-to-set-up-a-ci-cd-pipeline-for-your-ios-app-fastlane-github-actions
default_platform(:ios)
platform :ios do
desc 'Load ASC API Key information to use in subsequent lanes'
lane :load_asc_api_key do
app_store_connect_api_key(
key_id: ENV['ASC_KEY_ID'],
issuer_id: ENV['ASC_ISSUER_ID'],
key_content: ENV['ASC_KEY'],
is_key_content_base64: false,
in_house: false # Detecting this via ASC private key not currently supported
)
end
desc 'Generate build number based on number of commits'
lane :generate_build_number do
# Deterministically set the build number based on the number of commits
build_number = number_of_commits()
increment_build_number(
build_number: build_number
)
end
desc 'Installs signing certificate in the keychain and downloads provisioning profiles from App Store Connect'
lane :prepare_signing do |options|
team_id = CredentialsManager::AppfileConfig.try_fetch_value(:team_id)
api_key = lane_context[SharedValues::APP_STORE_CONNECT_API_KEY]
app_identifier = CredentialsManager::AppfileConfig.try_fetch_value(:app_identifier)
bundle_identifier = ENV['BUNDLE_ID'] || app_identifier
profile_name = ENV['PROV_PROFILE_NAME'] || 'Github'
adhoc = ENV['ADHOC'] === 'true'
widget_profile_name = ENV['WIDGET_PROV_PROFILE_NAME'] || 'HackerNewsHomeWidget Distribution'
keychain_name = 'signing'
keychain_password = 'temp'
delete_keychain(
name: keychain_name
) if File.exist? File.expand_path("~/Library/Keychains/#{keychain_name}-db")
create_keychain(
name: keychain_name,
password: keychain_password,
default_keychain: true,
unlock: true,
timeout: 3600
)
import_certificate(
certificate_path: ENV['SIGNING_KEY_FILE_PATH'],
certificate_password: ENV['SIGNING_KEY_PASSWORD'],
keychain_name: keychain_name,
keychain_password: keychain_password
)
# Fetches and installs provisioning profiles from ASC
sigh(
adhoc: adhoc,
api_key: api_key,
readonly: true,
provisioning_name: profile_name,
app_identifier: bundle_identifier
)
sigh(
adhoc: adhoc,
api_key: api_key,
readonly: true,
provisioning_name: widget_profile_name,
app_identifier: 'com.emergetools.hackernews.HackerNewsHomeWidget'
)
end
desc 'Build the iOS app'
lane :build_app_for_scheme do |options|
app_identifier = CredentialsManager::AppfileConfig.try_fetch_value(:app_identifier)
bundle_identifier = ENV['BUNDLE_ID'] || app_identifier
profile_name = ENV['PROV_PROFILE_NAME'] || 'Github'
adhoc = ENV['ADHOC'] === 'true'
widget_profile_name = ENV['WIDGET_PROV_PROFILE_NAME'] || 'HackerNewsHomeWidget Distribution'
output_name = 'hackernews-iOS' # .ipa name
export_method = 'app-store'
# Turn off automatic signing during build so correct code signing identity is guaranteed to be used
update_code_signing_settings(
use_automatic_signing: false,
targets: ['HackerNews', 'HackerNewsHomeWidgetExtension'],
code_sign_identity: 'Apple Distribution',
bundle_identifier: bundle_identifier,
profile_name: profile_name,
build_configurations: [ENV['CONFIGURATION']],
team_id: ENV['APPLE_TEAM_ID']
)
# Also update code signing for widget extension specifically
update_code_signing_settings(
use_automatic_signing: false,
targets: ['HackerNewsHomeWidgetExtension'],
code_sign_identity: 'Apple Distribution',
bundle_identifier: 'com.emergetools.hackernews.HackerNewsHomeWidget',
profile_name: widget_profile_name,
build_configurations: [ENV['CONFIGURATION']],
team_id: ENV['APPLE_TEAM_ID']
)
# build the app
build_ios_app(
scheme: 'HackerNews',
output_name: output_name,
configuration: ENV['CONFIGURATION'],
export_team_id: ENV['APPLE_TEAM_ID'],
export_options: {
method: export_method,
provisioningProfiles: {
bundle_identifier => profile_name,
'com.emergetools.hackernews.HackerNewsHomeWidget' => widget_profile_name
},
team_id: ENV['APPLE_TEAM_ID']
}
)
end
desc 'Upload to TestFlight / ASC'
lane :upload_app do
api_key = lane_context[SharedValues::APP_STORE_CONNECT_API_KEY]
deliver(
api_key: api_key,
skip_screenshots: true,
skip_metadata: true,
skip_app_version_update: true,
force: true, # Skips verification of HTML preview file (since this will be run from a CI machine)
run_precheck_before_submit: false # Not supported through ASC API yet
)
end
desc 'Build and upload to TestFlight + Emerge Tools'
lane :build_upload_testflight do
load_asc_api_key
prepare_signing
generate_build_number
build_app_for_scheme(build_configuration: 'Release')
upload_app
emerge(tag: ENV['EMERGE_BUILD_TYPE'])
# TODO(telkins)
# sentry_cli(
# org_slug: 'emerge-tools',
# project_slug: 'hackernews-ios',
# include_sources: true
# )
end
desc 'Build and upload to Emerge Tools'
lane :build_upload_emerge do
load_asc_api_key
prepare_signing
build_app_for_scheme(build_configuration: ENV['CONFIGURATION'])
emerge(
tag: ENV['EMERGE_BUILD_TYPE'],
app_id_suffix: ENV['APP_ID_SUFFIX']
)
end
desc 'Build and upload snapshot build to Emerge Tools'
lane :build_upload_emerge_snapshot do
emerge_snapshot(scheme: "HackerNews")
end
end