Skip to content

Commit 9301e33

Browse files
authored
Adds Fastlane setup (rootstrap#130)
1 parent f3806b0 commit 9301e33

File tree

5 files changed

+272
-18
lines changed

5 files changed

+272
-18
lines changed

Gemfile

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
source 'https://rubygems.org'
22

33
gem 'slather'
4+
5+
6+
gem "fastlane"

README.md

+17-3
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ To manage user and session persistence after the original sign in/up we store th
6060
4. Done :)
6161

6262
## Code Quality Standards
63-
In order to meet the required code quality standards, this project runs [SwiftLint](https://github.com/realm/SwiftLint )
63+
In order to meet the required code quality standards, this project runs [SwiftLint](https://github.com/realm/SwiftLint )
6464
during the build phase and reports warnings/errors directly through XCode.
65-
The current SwiftLint rule configuration is based on [Rootstrap's Swift style guides](https://rootstrap.github.io/swift) and is synced with
65+
The current SwiftLint rule configuration is based on [Rootstrap's Swift style guides](https://rootstrap.github.io/swift) and is synced with
6666
the CodeCliemate's configuration file.
67-
67+
6868
**NOTE:** Make sure you have SwiftLint version 0.35.0 or greater installed to avoid known false-positives with some of the rules.
6969

7070
## Security recommendations
@@ -80,6 +80,20 @@ We strongly recommend that all private keys be added to a `.plist` file that wil
8080
**Repeat this step for the Post-actions script.**
8181
4. Done :)
8282

83+
## CD using Fastlane
84+
Lanes for each deployment target are provided with some basic behavior:
85+
- Each target has two options: `build_x` and `release_x`.
86+
- The `build` lane will just archive the app and leave the `.ipa` ready for upload.
87+
- The `release` lane will:
88+
- Check the repo status (it has to be clean, with no pending changes)
89+
- Increment the build number.
90+
- Tag the new release and push it to the set branch (dev and staging push to develop and production to master by default, but it's configurable).
91+
- Build the app.
92+
- Generate a changelog from the commit diff between this new version and the previous.
93+
- Upload to testflight and wait until it's processed.
94+
95+
Check the `Appfile` and `Fastfile` for more information.
96+
8397
## License
8498

8599
iOS-Base is available under the MIT license. See the LICENSE file for more info.

fastlane/Appfile

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# app_identifier("[[APP_IDENTIFIER]]") # The bundle identifier of your app
2+
# apple_id("[[APPLE_ID]]") # Your Apple email address
3+
4+
5+
# For more information about the Appfile, see:
6+
# https://docs.fastlane.tools/advanced/#appfile
7+
8+
for_platform :ios do
9+
for_lane :release_develop do
10+
app_identifier('com.rootstrap.ios-base-Debug')
11+
end
12+
13+
for_lane :build_develop do
14+
app_identifier('com.rootstrap.ios-base-Debug')
15+
end
16+
17+
for_lane :release_staging do
18+
app_identifier('com.rootstrap.ios-base-Staging')
19+
end
20+
21+
for_lane :build_staging do
22+
app_identifier('com.rootstrap.ios-base-Staging')
23+
end
24+
25+
for_lane :release_production do
26+
app_identifier('com.rootstrap.ios-base')
27+
end
28+
29+
for_lane :build_production do
30+
app_identifier('com.rootstrap.ios-base')
31+
end
32+
end

fastlane/Fastfile

+209
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
# This file contains the fastlane.tools configuration
2+
# You can find the documentation at https://docs.fastlane.tools
3+
#
4+
# For a list of all available actions, check out
5+
#
6+
# https://docs.fastlane.tools/actions
7+
#
8+
# For a list of all available plugins, check out
9+
#
10+
# https://docs.fastlane.tools/plugins/available-plugins
11+
#
12+
13+
# Uncomment the line if you want fastlane to automatically update itself
14+
# update_fastlane
15+
16+
default_platform(:ios)
17+
18+
# CONFIG VARIABLES
19+
username = '[email protected]' # The apple id that you are using to admin the certificates eg: [email protected]
20+
xcodeproj = 'ios-base.xcodeproj' # The xcodeproj name eg: ReactNativeBase.xcodeproj
21+
workspace = 'ios-base.xcworkspace' # The xworkspace name here eg: ReactNativeBase.xcworkspace
22+
certificates_git_url = '' # The repo to store and sync certs and provisioning profiles. Eg: [email protected]:rootstrap/cafe-infinity-certificates.git
23+
team_id = '' # The organization's team id (you can leave this empty and select it on the CLI on each run)
24+
distribute_external = false # Change this to true if you want the build to be distributed to external testers as well.
25+
notify_external_testers = false
26+
skip_waiting_for_build_processing = false # Don't wait for the build to process. If set to true, the changelog won't be set, distribute_external option won't work and no build will be distributed to testers. (You might want to use this option if you are using this action on CI and have to pay for 'minutes used' on your CI plan)
27+
28+
platform :ios do
29+
lane :release_develop do
30+
sync_code_signing(
31+
git_url: certificates_git_url,
32+
username: username,
33+
type: 'appstore',
34+
team_id: team_id
35+
)
36+
37+
ensure_git_status_clean
38+
39+
increment_build_number(xcodeproj: xcodeproj)
40+
41+
commit_version_bump(xcodeproj: xcodeproj)
42+
43+
add_git_tag
44+
45+
push_to_git_remote(remote_branch: 'develop')
46+
47+
build_app(
48+
scheme: 'ios-base-develop',
49+
workspace: workspace,
50+
include_bitcode: true,
51+
export_method: 'app-store'
52+
)
53+
54+
changelog = changelog_from_git_commits(
55+
pretty: "- (%ae) %s",# Optional, lets you provide a custom format to apply to each commit when generating the changelog text
56+
date_format: "short",# Optional, lets you provide an additional date format to dates within the pretty-formatted string
57+
match_lightweight_tag: false, # Optional, lets you ignore lightweight (non-annotated) tags when searching for the last tag
58+
merge_commit_filtering: "exclude_merges" # Optional, lets you filter out merge commits
59+
)
60+
61+
upload_to_testflight(
62+
username: username,
63+
team_id: team_id,
64+
changelog: changelog,
65+
distribute_external: distribute_external,
66+
notify_external_testers: notify_external_testers,
67+
skip_waiting_for_build_processing: skip_waiting_for_build_processing
68+
)
69+
end
70+
71+
lane :release_staging do
72+
sync_code_signing(
73+
git_url: certificates_git_url,
74+
username: username,
75+
type: 'appstore',
76+
team_id: team_id
77+
)
78+
79+
ensure_git_status_clean
80+
81+
increment_build_number(xcodeproj: xcodeproj)
82+
83+
commit_version_bump(xcodeproj: xcodeproj)
84+
85+
add_git_tag
86+
87+
push_to_git_remote(remote_branch: 'develop')
88+
89+
build_app(
90+
scheme: 'ios-base-staging',
91+
workspace: workspace,
92+
include_bitcode: true,
93+
export_method: 'app-store'
94+
)
95+
96+
changelog = changelog_from_git_commits(
97+
pretty: "- (%ae) %s",# Optional, lets you provide a custom format to apply to each commit when generating the changelog text
98+
date_format: "short",# Optional, lets you provide an additional date format to dates within the pretty-formatted string
99+
match_lightweight_tag: false, # Optional, lets you ignore lightweight (non-annotated) tags when searching for the last tag
100+
merge_commit_filtering: "exclude_merges" # Optional, lets you filter out merge commits
101+
)
102+
103+
upload_to_testflight(
104+
username: username,
105+
team_id: team_id,
106+
changelog: changelog,
107+
distribute_external: distribute_external,
108+
notify_external_testers: notify_external_testers,
109+
skip_waiting_for_build_processing: skip_waiting_for_build_processing
110+
)
111+
end
112+
113+
lane :release_production do
114+
sync_code_signing(
115+
git_url: prod_certificates_git_url,
116+
username: username,
117+
type: 'appstore',
118+
team_id: team_id
119+
)
120+
121+
ensure_git_status_clean
122+
123+
increment_build_number(xcodeproj: xcodeproj)
124+
125+
commit_version_bump(xcodeproj: xcodeproj)
126+
127+
add_git_tag
128+
129+
push_to_git_remote(remote_branch: 'master')
130+
131+
build_app(
132+
scheme: 'ios-base',
133+
workspace: workspace,
134+
include_bitcode: true,
135+
export_method: 'app-store'
136+
)
137+
138+
changelog = changelog_from_git_commits(
139+
pretty: "- (%ae) %s",# Optional, lets you provide a custom format to apply to each commit when generating the changelog text
140+
date_format: "short",# Optional, lets you provide an additional date format to dates within the pretty-formatted string
141+
match_lightweight_tag: false, # Optional, lets you ignore lightweight (non-annotated) tags when searching for the last tag
142+
merge_commit_filtering: "exclude_merges" # Optional, lets you filter out merge commits
143+
)
144+
145+
upload_to_testflight(
146+
username: "[email protected]",
147+
team_id: team_id,
148+
changelog: changelog,
149+
distribute_external: distribute_external,
150+
notify_external_testers: notify_external_testers,
151+
skip_waiting_for_build_processing: skip_waiting_for_build_processing
152+
)
153+
end
154+
155+
lane :build_develop do
156+
sync_code_signing(
157+
git_url: certificates_git_url,
158+
username: username,
159+
type: 'appstore',
160+
team_id: team_id
161+
)
162+
163+
increment_build_number(xcodeproj: xcodeproj)
164+
165+
build_app(
166+
scheme: 'ios-base-develop',
167+
workspace: workspace,
168+
include_bitcode: true,
169+
export_method: 'app-store'
170+
)
171+
end
172+
173+
lane :build_staging do
174+
sync_code_signing(
175+
git_url: certificates_git_url,
176+
username: username,
177+
type: 'appstore',
178+
team_id: team_id
179+
)
180+
181+
increment_build_number(xcodeproj: xcodeproj)
182+
183+
build_app(
184+
scheme: 'ios-base-staging',
185+
workspace: workspace,
186+
include_bitcode: true,
187+
export_method: 'app-store'
188+
)
189+
end
190+
191+
lane :build_production do
192+
sync_code_signing(
193+
git_url: prod_certificates_git_url,
194+
username: username,
195+
type: 'appstore',
196+
team_id: team_id
197+
)
198+
199+
increment_build_number(xcodeproj: xcodeproj)
200+
201+
build_app(
202+
scheme: 'ios-base',
203+
workspace: workspace,
204+
include_bitcode: true,
205+
export_method: 'app-store'
206+
)
207+
end
208+
end
209+

ios-base.xcodeproj/xcshareddata/xcschemes/ios-base-develop.xcscheme

+11-15
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,17 @@
6262
buildConfiguration = "Debug"
6363
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
6464
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
65-
codeCoverageEnabled = "YES"
66-
shouldUseLaunchSchemeArgsEnv = "YES">
65+
shouldUseLaunchSchemeArgsEnv = "YES"
66+
codeCoverageEnabled = "YES">
67+
<MacroExpansion>
68+
<BuildableReference
69+
BuildableIdentifier = "primary"
70+
BlueprintIdentifier = "9B5AFAD91C7205EB002347D6"
71+
BuildableName = "ios-base.app"
72+
BlueprintName = "ios-base"
73+
ReferencedContainer = "container:ios-base.xcodeproj">
74+
</BuildableReference>
75+
</MacroExpansion>
6776
<Testables>
6877
<TestableReference
6978
skipped = "NO">
@@ -76,17 +85,6 @@
7685
</BuildableReference>
7786
</TestableReference>
7887
</Testables>
79-
<MacroExpansion>
80-
<BuildableReference
81-
BuildableIdentifier = "primary"
82-
BlueprintIdentifier = "9B5AFAD91C7205EB002347D6"
83-
BuildableName = "ios-base.app"
84-
BlueprintName = "ios-base"
85-
ReferencedContainer = "container:ios-base.xcodeproj">
86-
</BuildableReference>
87-
</MacroExpansion>
88-
<AdditionalOptions>
89-
</AdditionalOptions>
9088
</TestAction>
9189
<LaunchAction
9290
buildConfiguration = "Debug"
@@ -114,8 +112,6 @@
114112
isEnabled = "YES">
115113
</CommandLineArgument>
116114
</CommandLineArguments>
117-
<AdditionalOptions>
118-
</AdditionalOptions>
119115
</LaunchAction>
120116
<ProfileAction
121117
buildConfiguration = "Debug"

0 commit comments

Comments
 (0)