Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Automate some iOS development processes with Fastlane
fastlane_version "1.99.0"
REQUIRED_XCODE_VERSION = "7.3.1"
default_platform :ios
platform :ios do
before_all do |lane, options|
ENV["SLACK_URL"] = "https://hooks.slack.com/services/???"
end
error do |lane, exception, options|
if options[:slack]
slack(message: "<APP_SCHEME> iOS: " + exception.message, success: false)
end
end
#########
# LANES #
#########
desc "Setup workspace"
lane :setup do
## Setup pre-commit hook
sh "ln -s scripts/pre-commit.sh .git/hooks/pre-commit"
## Setup badge to add a beta watermark to your iOS app icon
sh "gem install badge"
## Install CocoaPods
# Remove old versions
sh "gem uninstall cocoapods -aIx"
# v1
sh "gem install cocoapods -v '1.0.1' --no-rdoc --no-ri --no-document --quiet"
## Install Carthage
sh "brew install carthage || true"
## Verify project dependencies
carthage update
cocoapods
end
desc "Runs test suite"
lane :test do |options|
# Test app
scan skip_slack: (not options[:slack])
end
desc "Increment the version and build number"
lane :version_bump_project do |options|
# Set build number to current date and time
build_number = Time.new.strftime("%Y.%m.%d.%H.%M")
ENV["BUILD_NUMBER"] = build_number
increment_build_number build_number: build_number
# Set version number conforming the bump type
if options[:bump_type]
increment_version_number bump_type: options[:bump_type]
end
end
desc "Submit a new beta to **TestFlight** and **Crashlytics**"
lane :beta do |options|
# Test suite
test slack: options[:slack]
# Bump
version_bump_project bump_type: options[:bump]
# Beta badge app icon
badge(dark: true)
## Crashlytics
# Provisioning Profile
match(type: "adhoc")
puts "Adhoc UDID: "+ENV["sigh_<PRODUCT_BUNDLE_IDENTIFIER>_adhoc"]
# Build
gym(
scheme: "<APP_SCHEME>",
export_method: "ad-hoc",
suppress_xcode_output: false,
xcargs: "APP_PROFILE='#{ENV["sigh_<PRODUCT_BUNDLE_IDENTIFIER>_adhoc"]}'",
)
crashlytics(
api_token: "???",
build_secret: "???",
ipa_path: "./build/<APP_SCHEME>.ipa",
notes: "Build at " + Time.new.strftime("%H:%M:%S %d.%m.%Y")
)
## TestFlight
# Provisioning Profile
match(type: "appstore")
puts "AppStore UDID: "+ENV["sigh_<PRODUCT_BUNDLE_IDENTIFIER>_appstore"]
# Build
gym(
scheme: "<APP_SCHEME>",
export_method: "app-store",
suppress_xcode_output: true,
xcargs: "APP_PROFILE='#{ENV["sigh_<PRODUCT_BUNDLE_IDENTIFIER>_appstore"]}'",
)
# Submit to iTunes Connect
pilot(
skip_submission: true,
skip_waiting_for_build_processing: true
) # Skip the distribution of the app to all beta testers
# Success
build_number = ENV["BUILD_NUMBER"]
if build_number and options[:slack]
slack(message: "<APP_SCHEME> iOS: build " + build_number + " is ready.")
end
clean_build_artifacts
end
desc "Submit a new version to iTunes Connect"
lane :release do |options|
# Test suite
test slack: options[:slack]
# Bump
version_bump_project bump_type: options[:bump]
# Steps
# Certs & Provisioning Profiles
match(type: "appstore")
puts "AppStore UDID: "+ENV["sigh_<PRODUCT_BUNDLE_IDENTIFIER>_appstore"]
# Build your app
gym(
scheme: "<APP_SCHEME>",
export_method: "app-store",
suppress_xcode_output: false,
xcargs: "APP_PROFILE='#{ENV["sigh_<PRODUCT_BUNDLE_IDENTIFIER>_appstore"]}'",
)
# iTunes Connect
pilot(skip_submission: true)
# Success
build_number = ENV["BUILD_NUMBER"]
if build_number and options[:slack]
slack(message: "<APP_SCHEME> iOS: build " + build_number + " is ready.")
end
clean_build_artifacts
end
end
@ricardopereira

This comment has been minimized.

Copy link
Owner Author

commented Aug 5, 2016

Example, if you want to run a beta lane because of a small bug fix, you can do it like:
fastlane beta bump:patch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.