Towards Continuous Delivery with
@attheodo
What is Fastlane?
-
A set of tools written on Ruby.
-
You define and run sets of tasks (lanes) for different environments and configurations.
-
Automates deployment/release process.
-
100% open-source, fully extendable and configurable.
-
Saves you time and frustration.
1
Fastlane Tools
Upload screenshots, metadata and your app to the App Store using a single command.
Fastlane Tools
Automate taking localized screenshots of your iOS app on every device.
Fastlane Tools
Automagically generate and renew your push notification profiles.
Fastlane Tools
Fixes provisioning issues without you having to cut your wrists.
Fastlane Tools
Create new iOS apps on iTunes Connect and Developer Portal using the command line
Fastlane Tools
Create and maintain iOS code signing certificates in an automatic way
Fastlane Tools
The easiest way to run tests of your iOS and Mac apps.
Fastlane Tools
"Building your iOS app has never been easier"
Fastlane Tools
The best way to manage your Testflight testers and builds from your terminal
Fastlane Tools
-
There are another two or three...
-
Available as standalone from CLI.
-
Based on the solid....
A Ruby Library that exposes Apple Developer Center and iTunes Connect as API
Fastlane Tools
Installation
You guessed it. It's a gem.
$ sudo gem install fastlane --verbose
Quickstart
$ cd MyAwesomeApp; fastlane init
Gets you a boilerplate Fastfile
Gets you a boilerplate AppFile
Appfile
-
Stores useful information that is used across all fastlane tools.
-
Your App Identifier
-
Your Apple ID
-
Your iTunes Connect Team Name
-
Your Apple Dev Portal Id
-
Your iTunes Connect Account
Appfile
app_identifier "com.MyCompany.MyApp"
apple_dev_portal_id "me@mycoolhost.com"
itunes_connect_id "thanos@atworks.gr"
team_name "Kick-ass Devs, Inc."
team_id "DEADB33F"
itc_team_name "Kick-ass Devs, Inc"
itc_team_id "B4DF00D"
Fastfile
-
Where you define your set of tasks (lanes)
-
i.e App Store Release, Testflight Release, Ad-Hoc Release, Testing
-
Each lane is comprised of "Actions"
Fastfile
# Fastfile
lane :appstore do
# whatever actions you want for an App Store release
end
lane :testflight do
# whatever actions you want for a Testflight release
end
-
Defining lanes is easy
Fastfile
# Fastfile
before_all do |lane|
# Executed before running the requested lane
# Supports the same actions as lanes
end
after_all do |lane|
# Executed after running the requested lane and
# the lane ran succesfully.
end
error do |lane, exception|
# Executed when an error occurs in any of the
# `before_all`, the lane itself or `after_all` blocks
end
-
Helper blocks
Actions
# Example Actions
cocoapods # this will run pod install
increment_version_number( # Makes app version from 1.1.0 to 1.2.0
bump_type: "minor"
)
changelog_from_git_commits # Turns your git history into CHANGELOG
ensure_git_branch( # Makes sure you're on the "release" branch
branch: 'release'
)
ensure_git_status_clean # Ensures no uncommited changes get deployed
push_to_git_remote # Pushes `master` branch to `origin` remote
push_git_tags # Pushes only tags and nothing else
Numerous predefined "tasks" to use in your lanes.
Actions
# Run tests
scan(
workspace: "MyApp.xcworkspace",
scheme: "MyTests",
clean: false
)
# Build an IPA out of the app
gym(
workspace: "MyApp.xcworkspace",
configuration: "Debug",
scheme: "MyApp",
silent: true,
clean: true, # clean build folder first
output_directory: "path/to/dir",
output_name: "my-app.ipa"
)
Fastlane tools are also actions!
Real-life example
before_all do
ENV["SLACK_URL"] = "https://hooks.slack.com/services/[REDACTED]"
cocoapods
end
lane :test do
desc "Run all tests in an iPad Air 2 Simulator"
test_app
end
def test_app
scan(
scheme: "RevealFootball",
configuration: "Testing",
clean: false,
device: "iPad Air 2",
skip_slack: true
)
end
lane :appstore do
test_app
ensure_git_branch(branch: 'release')
ensure_git_status_clean
increment_version_number(
bump_type: "minor"
)
gym(
scheme: "RevealFootball",
configuration: "Release",
output_directory: "./build/release",
silent: true,
clean: true
)
deliver(
ipa: "./build/release/Reveal Football.ipa",
app_identifier: "com.insightreplay.Reveal-Football",
skip_screenshots: true,
skip_metadata: true
)
commit_version_bump(
message: "Build version bump by build script",
force: true
)
version_number = Actions.lane_context[Actions::SharedValues::VERSION_NUMBER]
add_git_tag(
tag: "Release-v#{version_number}"
)
push_to_git_remote
slack(
message: "Reveal Football (#{version_number}) submitted to the App Store for review and release 😎",
channel: "#reveal-ios",
success: true,
)
end
lane :testflight do
ensure_git_branch('develop')
ensure_git_status_clean
increment_build_number
commit_version_bump
gym(
scheme: "RevealFootball",
configuration: "Testflight",
output_directory: "./build/beta",
silent: true,
clean: true
)
pilot(
ipa: "./build/beta/Reveal Football.ipa",
app_identifier: "com.insightreplay.Reveal-Football.testflight",
skip_submission: true
)
slack(
message: "New Testflight build pushed to ITC.",
channel: "#reveal-ios",
success: true,
)
end
Real-life example (testflight lane)
RTFM
-
https://github.com/fastlane/fastlane
-
.../tree/master/fastlane/docs
-
https://github.com/fastlane/examples
Satisfaction Guaranteed.
Questions?
@attheodo
http://attheo.do
Towards Continuous Delivery with Fastlane
By Thanos Theodoridis
Towards Continuous Delivery with Fastlane
- 473