Skip to content

Commit ff8e86c

Browse files
authored
ci(fastlane): add retry logic for pod push and missing versioning logic (#610)
1 parent c207b96 commit ff8e86c

File tree

4 files changed

+101
-45
lines changed

4 files changed

+101
-45
lines changed

.circleci/config.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version: 2.1
44

55
defaults: &defaults
66
macos:
7-
xcode: "11.4.0"
7+
xcode: '11.4.1'
88
working_directory: ~/amplify-ios
99
environment:
1010
BUNDLE_PATH: vendor/bundle
@@ -44,8 +44,8 @@ commands:
4444
steps:
4545
- restore_cache:
4646
keys:
47-
- v1-gems-{{ checksum "~/amplify-ios/Gemfile.lock" }}
48-
- v1-gems-
47+
- v2-gems-{{ checksum "~/amplify-ios/Gemfile.lock" }}
48+
- v2-gems-
4949

5050
check_bundle:
5151
steps:
@@ -96,7 +96,7 @@ jobs:
9696
BUNDLE_JOBS: 4
9797
BUNDLE_RETRY: 3
9898
- save_cache:
99-
key: v1-gems-{{ checksum "~/amplify-ios/Gemfile.lock" }}
99+
key: v2-gems-{{ checksum "~/amplify-ios/Gemfile.lock" }}
100100
paths:
101101
- vendor/bundle
102102

@@ -152,19 +152,19 @@ jobs:
152152
parameters:
153153
lane:
154154
type: string
155-
default: "unstable"
155+
default: 'unstable'
156156
description: deploy pods to trunk
157157
steps:
158158
- add_ssh_keys:
159159
fingerprints:
160-
- "80:9a:29:87:ac:5f:1a:9b:c5:a4:3d:37:c1:10:87:2f"
160+
- '80:9a:29:87:ac:5f:1a:9b:c5:a4:3d:37:c1:10:87:2f'
161161
- *restore_repo
162162
- restore_gems
163163
- check_bundle
164164
- run:
165165
name: Release pods
166166
command: bundle exec fastlane << parameters.lane >>
167-
no_output_timeout: 20m
167+
no_output_timeout: 60m
168168

169169
deploy_requires: &deploy_requires
170170
requires:

Gemfile.lock

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
GIT
22
remote: https://github.com/aws-amplify/amplify-ci-support
3-
revision: d6ccaffae0c1fd6426d9209fffa04f7300377726
3+
revision: e484c7fb9ee9b156f450af83a282cc1a31a74c5d
44
branch: master
55
glob: src/fastlane/release_actions/*.gemspec
66
specs:
7-
fastlane-plugin-release_actions (1.0.3)
7+
fastlane-plugin-release_actions (1.0.4)
88

99
GEM
1010
remote: https://rubygems.org/
@@ -22,16 +22,16 @@ GEM
2222
json (>= 1.5.1)
2323
atomos (0.1.3)
2424
aws-eventstream (1.1.0)
25-
aws-partitions (1.337.0)
26-
aws-sdk-core (3.102.1)
25+
aws-partitions (1.339.0)
26+
aws-sdk-core (3.103.0)
2727
aws-eventstream (~> 1, >= 1.0.2)
2828
aws-partitions (~> 1, >= 1.239.0)
2929
aws-sigv4 (~> 1.1)
3030
jmespath (~> 1.0)
31-
aws-sdk-kms (1.35.0)
31+
aws-sdk-kms (1.36.0)
3232
aws-sdk-core (~> 3, >= 3.99.0)
3333
aws-sigv4 (~> 1.1)
34-
aws-sdk-s3 (1.72.0)
34+
aws-sdk-s3 (1.73.0)
3535
aws-sdk-core (~> 3, >= 3.102.1)
3636
aws-sdk-kms (~> 1)
3737
aws-sigv4 (~> 1.1)
@@ -83,11 +83,12 @@ GEM
8383
concurrent-ruby (1.1.6)
8484
declarative (0.0.20)
8585
declarative-option (0.1.0)
86-
digest-crc (0.5.1)
86+
digest-crc (0.6.1)
87+
rake (~> 13.0)
8788
domain_name (0.5.20190701)
8889
unf (>= 0.0.5, < 1.0.0)
8990
dotenv (2.7.5)
90-
emoji_regex (1.0.1)
91+
emoji_regex (3.0.0)
9192
escape (0.0.4)
9293
ethon (0.12.0)
9394
ffi (>= 1.3.0)
@@ -100,16 +101,16 @@ GEM
100101
faraday_middleware (1.0.0)
101102
faraday (~> 1.0)
102103
fastimage (2.1.7)
103-
fastlane (2.149.1)
104+
fastlane (2.151.1)
104105
CFPropertyList (>= 2.3, < 4.0.0)
105106
addressable (>= 2.3, < 3.0.0)
106107
aws-sdk-s3 (~> 1.0)
107-
babosa (>= 1.0.2, < 2.0.0)
108+
babosa (>= 1.0.3, < 2.0.0)
108109
bundler (>= 1.12.0, < 3.0.0)
109110
colored
110111
commander-fastlane (>= 4.4.6, < 5.0.0)
111112
dotenv (>= 2.1.1, < 3.0.0)
112-
emoji_regex (>= 0.1, < 2.0)
113+
emoji_regex (>= 0.1, < 4.0)
113114
excon (>= 0.71.0, < 1.0.0)
114115
faraday (>= 0.17, < 2.0)
115116
faraday-cookie_jar (~> 0.0.6)
@@ -120,13 +121,11 @@ GEM
120121
google-cloud-storage (>= 1.15.0, < 2.0.0)
121122
highline (>= 1.7.2, < 2.0.0)
122123
json (< 3.0.0)
123-
jwt (~> 2.1.0)
124+
jwt (>= 2.1.0, < 3)
124125
mini_magick (>= 4.9.4, < 5.0.0)
125-
multi_xml (~> 0.5)
126126
multipart-post (~> 2.0.0)
127127
plist (>= 3.1.0, < 4.0.0)
128-
public_suffix (~> 2.0.0)
129-
rubyzip (>= 1.3.0, < 2.0.0)
128+
rubyzip (>= 2.0.0, < 3.0.0)
130129
security (= 0.1.3)
131130
simctl (~> 1.6.3)
132131
slack-notifier (>= 2.0.0, < 3.0.0)
@@ -178,30 +177,30 @@ GEM
178177
concurrent-ruby (~> 1.0)
179178
jmespath (1.4.0)
180179
json (2.3.1)
181-
jwt (2.1.0)
180+
jwt (2.2.1)
182181
memoist (0.16.2)
183182
mini_magick (4.10.1)
184183
mini_mime (1.0.2)
185184
minitest (5.14.1)
186185
molinillo (0.6.6)
187186
multi_json (1.14.1)
188-
multi_xml (0.6.0)
189187
multipart-post (2.0.0)
190188
nanaimo (0.2.6)
191189
nap (1.1.0)
192190
naturally (2.2.0)
193191
netrc (0.11.0)
194192
os (1.1.0)
195193
plist (3.5.0)
196-
public_suffix (2.0.5)
194+
public_suffix (4.0.5)
195+
rake (13.0.1)
197196
representable (3.0.4)
198197
declarative (< 0.1.0)
199198
declarative-option (< 0.2.0)
200199
uber (< 0.2.0)
201200
retriable (3.1.2)
202201
rouge (2.0.7)
203202
ruby-macho (1.4.0)
204-
rubyzip (1.3.0)
203+
rubyzip (2.3.0)
205204
security (0.1.3)
206205
signet (0.14.0)
207206
addressable (~> 2.3)
@@ -251,4 +250,4 @@ DEPENDENCIES
251250
xcpretty
252251

253252
BUNDLED WITH
254-
1.17.2
253+
2.1.2

fastlane/Fastfile

Lines changed: 61 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ platform :ios do
3333

3434
changelog = build_changelog(version: next_version, commits: commits)
3535

36-
write_changelog(changelog: changelog, path: 'CHANGELOG.md')
37-
3836
# Commit and push
3937
release_commit(version: next_version)
4038

@@ -43,6 +41,8 @@ platform :ios do
4341

4442
# Push pods
4543
release_pods()
44+
45+
post_release(version: next_version, changelog: changelog)
4646
end
4747

4848
desc "Increment versions"
@@ -61,7 +61,10 @@ platform :ios do
6161
plist_paths.each do |plist_path|
6262
set_info_plist_value(path: plist_path, key: PLIST_KEY, value: version)
6363
end
64-
end
64+
65+
# One-offs
66+
set_key_value(file: "AmplifyPlugins/Core/AWSPluginsCore/ServiceConfiguration/AmplifyAWSServiceConfiguration.swift", key: "version", value: version)
67+
set_key_value(file: "build-support/dependencies.rb", key: "AMPLIFY_VERSION", value: version)
6568
end
6669

6770
desc "Commit and push"
@@ -73,8 +76,9 @@ platform :ios do
7376

7477
commit_message = "chore: release #{next_version} [skip ci]"
7578
sh('git', 'commit', '-am', commit_message)
79+
80+
# push to origin
7681
sh('git', 'push', 'origin', 'release')
77-
sh('git', 'push', 'origin', 'release:main')
7882
end
7983

8084
desc "Tag in git and push to GitHub"
@@ -89,26 +93,67 @@ platform :ios do
8993
desc "Release pods"
9094
private_lane :release_pods do
9195
AmplifyPods.pods.each do |pod|
92-
pod_path = "/Users/distiller/amplify-ios/#{pod[:spec]}"
96+
if pod[:no_push]
97+
UI.message "Skipping pushing pod #{pod[:spec]}"
98+
next
99+
end
93100

94-
UI.message("Pushing pod #{pod[:spec]}")
101+
pod_path = "#{ENV['CIRCLE_WORKING_DIRECTORY']}/#{pod[:spec]}"
95102

96-
dupe_error = "[!] Unable to accept duplicate entry"
103+
UI.message "Pushing pod #{pod[:spec]}"
97104

98-
begin
99-
sh('bundle', 'exec', 'pod', 'trunk', 'push', pod_path, '--allow-warnings', '--synchronous')
100-
rescue => ex
101-
unless ex.to_s.include? dupe_error
102-
raise Exception.new "Unrecoverable error in pod push trunk"
105+
with_retry do
106+
begin
107+
pod_push(path: pod[:spec], allow_warnings: true, synchronous: true)
108+
rescue exception
109+
raise exception unless exception.message =~ /Unable to accept duplicate entry/i
110+
UI.warn("Version already exists. Ignoring")
103111
end
104112
end
105113

106-
# TODO: utilize action once the PR for adding `synchronous` options has been merged
107-
# https://github.com/fastlane/fastlane/pull/16698
108-
# pod_push(path: pod[:spec], allow_warnings: true, synchronous: true)
109-
110114
# This shouldn't be necessary... but it is
111115
sh('bundle', 'exec', 'pod', 'repo', 'update')
112116
end
113117
end
118+
119+
desc "Post-release"
120+
private_lane :post_release do |options|
121+
version = options[:version].to_s
122+
changelog = options[:changelog]
123+
tag = "v#{version}"
124+
# increment plugin lock files by calling pod update on each
125+
plugin_root = "#{ENV['CIRCLE_WORKING_DIRECTORY']}/AmplifyPlugins"
126+
127+
sh('bundle', 'exec', 'pod', 'repo', 'update')
128+
129+
AmplifyPods.plugins.each do |plugin|
130+
path = "#{plugin_root}/#{plugin}"
131+
Dir.chdir(path){ sh('pod', 'update') }
132+
end
133+
134+
write_changelog(changelog: changelog, path: 'CHANGELOG.md')
135+
136+
commit_message = "chore: finalize release #{version} [skip ci]"
137+
sh('git', 'commit', '-am', commit_message)
138+
139+
add_git_tag(tag: tag, force: true)
140+
push_git_tags(tag: tag, force: true)
141+
142+
# push to origin
143+
sh('git', 'push', 'origin', 'release')
144+
sh('git', 'push', 'origin', 'release:main')
145+
end
114146
end
147+
148+
def with_retry(retries=5, wait=10)
149+
begin
150+
yield
151+
rescue e
152+
retries -= 1
153+
raise e if retries.zero?
154+
UI.error("Error occurred: #{exception}; retrying...")
155+
sleep(wait)
156+
retry
157+
end
158+
end
159+
end

fastlane/amplify_pods.rb

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ module AmplifyPods
1515
spec: "AWSPluginsCore.podspec",
1616
constants: ['AMPLIFY_VERSION'],
1717
plist_paths: [
18+
"AmplifyPlugins/Core/AWSPluginsTestCommon/Info.plist",
1819
"AmplifyPlugins/Core/AWSPluginsCore/Info.plist",
19-
"AmplifyPlugins/Core/AWSPluginsCoreTests/Info.plist",
20-
"AmplifyPlugins/Core/AWSPluginsTestCommon/Info.plist"
20+
"AmplifyPlugins/Core/AWSPluginsCoreTests/Info.plist"
2121
]
2222
},
2323
{
@@ -40,11 +40,23 @@ module AmplifyPods
4040
plist_paths: [
4141
"AmplifyPlugins/Analytics/AWSPinpointAnalyticsPlugin/Resources/Info.plist",
4242
"AmplifyPlugins/API/AWSAPICategoryPlugin/Info.plist",
43+
"AmplifyPlugins/Auth/AWSCognitoAuthPlugin/Resources/Info.plist",
44+
"AmplifyPlugins/DataStore/AWSDataStoreCategoryPlugin/Info.plist",
4345
"AmplifyPlugins/Storage/AWSS3StoragePlugin/Resources/Info.plist"
4446
]
47+
},
48+
{
49+
spec: "AmplifyTestCommon.podspec",
50+
constants: ['AMPLIFY_VERSION'],
51+
plist_paths: [],
52+
no_push: true
4553
}
4654
]
55+
@@plugins = ['API', 'Analytics', 'Auth', 'DataStore', 'Predictions', 'Storage']
4756
def self.pods
4857
@@pods
4958
end
59+
def self.plugins
60+
@@plugins
61+
end
5062
end

0 commit comments

Comments
 (0)