-
Notifications
You must be signed in to change notification settings - Fork 368
/
Fastfile
227 lines (177 loc) Β· 6.2 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
# AUTHOR: Fabio Milano < @iamfabiomilano >
require 'yaml'
require 'ostruct'
fastlane_version "1.14.0"
default_platform :ios
platform :ios do
before_all do
end
desc "Submit a new daily build to Crashlytics"
desc "A daily build is sent to Touchwonders team by default"
lane :development do |options|
# Kick off private lane
config_env(options)
prepare(remote_branch: options[:remote_branch])
# Download all requred provisioning profiles
get_provisioning_profile(options.merge(lane_name: 'development'))
# Last step before 'build&archive'
project_warm_up(options.merge(lane_name: 'development'))
# Send the project to take a "build and archive" treatment
build_and_archive(options.merge(lane_name: 'development'))
# Publish the result
publish(options)
end
desc "Deploy a new stable version"
desc "Sprint end weekly build"
lane :stable do |options|
# Kick off
config_env(options)
prepare(remote_branch: options[:remote_branch])
# Download all required provisioning profiles
get_provisioning_profile(options.merge(lane_name: 'stable'))
# Last step before 'build&archive'
project_warm_up(options.merge(lane_name: 'stable'))
# Send the project to take a "build and archive" treatment
build_and_archive(options.merge(lane_name: 'stable'))
# Publish the result
publish(options)
end
desc "Deploy a new version to the App Store"
desc "App Store build!"
lane :release do |options|
# Kick off
config_env(options)
prepare(remote_branch: options[:remote_branch])
# Download all required provisioning profiles
get_provisioning_profile(options.merge(lane_name: 'release'))
# Last step before 'build&archive'
project_warm_up(options.merge(lane_name: 'release'))
# Send the project to take a "build and archive" treatment
build_and_archive(options.merge(lane_name: 'release'))
# Upload to iTunes Connect
deliver(
skip_deploy: true,
force: true
)
end
# PRIVATE LANES
private_lane :config_env do |options|
# Select proper xcode tool
xcode = options[:xcode_select]
end
private_lane :prepare do |options|
ensure_git_status_clean
current_branch = git_branch
# # Checkout remote branch if needed
if !options[:remote_branch].nil? && options[:remote_branch] != current_branch
puts "Checkout new branch #{options[:remote_branch]}"
git_checkout(remote_branch: options[:remote_branch])
else
git_pull
end
cocoapods
end
private_lane :get_provisioning_profile do |options|
# Get targets
config = YAML.load(open(File.join(File.dirname(__FILE__),"fastlane_config.yaml")))
settings = OpenStruct.new(config)
lane_setting = settings[options[:lane_name]]
targets = lane_setting['targets']
username = "{developer_account_of_our_ci_server [at] touchwonders [dot] com}"
username = lane_setting['developer_portal_account_id'] if lane_setting['developer_portal_account_id']
targets.each do |target_setting|
# Get the latest provisionnig profiles from the Dev Portal
udid = sigh(username: username,
team_id: options[:team_id],
app_identifier: target_setting['app_identifier'],
output_path: "/tmp")
ENV["#{target_setting['target_identifier']}_UDID"] = udid
ENV["#{target_setting['target_identifier']}_PROVISIONING_PATH"] = Actions.lane_context[SharedValues::SIGH_PROFILE_PATH]
end
end
private_lane :build_and_archive do |options|
# Get configurations
config = YAML.load(open(File.join(File.dirname(__FILE__), "fastlane_config.yaml")))
settings = OpenStruct.new(config)
lane_setting = settings[options[:lane_name]]
# Make sure current directory is clean
File.delete("../#{settings['scheme']}.ipa") if File.exist? "../#{settings['scheme']}.ipa"
gym(
scheme: settings['scheme'],
provisioning_profile_path: ENV["PROJECT_PROVISIONING_PATH"],
configuration: lane_setting['configuration'],
output_name: "#{settings['scheme']}",
workspace: "#{settings['scheme']}.xcworkspace",
sdk: "#{options[:sdk]}"
)
end
private_lane :publish do |options|
load_release_notes(
ui_prompt: false
)
crashlytics(
crashlytics_path: './Pods/Crashlytics/Crashlytics.framework',
api_token: 'API_TOKEN',
build_secret: 'BUILD_SECRET',
ipa_path: "#{Actions.lane_context[SharedValues::IPA_OUTPUT_PATH]}",
groups: options[:groups],
notifications: options[:notifications],
notes_path: Actions.lane_context[SharedValues::LOAD_BUILD_NOTES_FILE_PATH]
)
end
private_lane :project_warm_up do |options|
# Get configurations
config = YAML.load(open(File.join(File.dirname(__FILE__), "fastlane_config.yaml")))
settings = OpenStruct.new(config)
lane_setting = settings[options[:lane_name]]
# EXPERIMENTAL START
# Add app icon overlay if needed
if lane_setting['add_icon_overlay']
case options['lane_name']
when 'development'
add_icon_overlay(
overlay_image_path: 'actions/assets/nightly_ribbon.png',
appiconset_path: lane_setting['appiconset_path']
)
when 'stable'
add_icon_overlay(
overlay_image_path: 'actions/assets/dev_ribbon.png',
appiconset_path: lane_setting['appiconset_path']
)
else
# No overlay has been requested.
end
end
# EXPERIMENTAL END
# Increment build number if needed
case options['lane_name']
when 'release'
# No increment build number required.
else
increment_build_number
end
end
# AFTER CALLBACKS
after_all do |lane|
slack(
message: "Successfully deployed new #{lane} build (#{Actions.lane_context[SharedValues::BUILD_NUMBER]}).",
payload: {
'What\'s new' => Actions.lane_context[SharedValues::LOAD_BUILD_NOTES_TEXT]
}
)
# Make sure our directory is clean, except for changes Fastlane has made
clean_build_artifacts
# Commit new build and push to git
git_commit
push_to_git_remote
end
error do |lane, exception|
reset_git_repo(
force: true
)
slack(
message: exception.message,
success: false
)
end
end