Last active
May 24, 2022 17:46
-
-
Save pjechris/e2eea3175a1bb5be67069b1023072f9e to your computer and use it in GitHub Desktop.
fastlane
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# you can even provide different app identifiers, Apple IDs and team names per lane: | |
# More information: https://github.com/fastlane/fastlane/blob/master/docs/Appfile.md | |
app_identifier ENV["APP_IDENTIFIER"] # The bundle identifier of your app | |
# You will have to set APP_IDENTIFIER into your .env files | |
apple_id ENV["APPLE_ID"] # Your Apple email address | |
team_id ENV["TEAM_ID"] # Developer Portal Team ID |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -------- | |
# Fastlane lanes based on --env option | |
# -------- | |
# Use action import(_from_git) into your Fastfile to use this file | |
# See https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Advanced.md#importing-another-fastfile | |
# To configure it: | |
# - Use environment actions variables (SIGH_*, GYM_*, ...) into .env.* files | |
# - Override (private)lanes into your custom Fastfile | |
platform :ios do | |
before_all do | |
define_optional_envs() | |
end | |
desc "Builds and deploys application" | |
lane :deploy do | |
set_build_number() | |
verify_release() if ENV["VERIFY_RELEASE"] == "true" | |
build() | |
upload_symbols_to_crashlytics() | |
crashlytics() if ENV['DEPLOY_CRASHLYTICS'] == 'true' | |
pilot() if ENV['DEPLOY_TESTFLIGHT'] == 'true' | |
slack(message: "build ##{get_version_number}-#{lane_context[:BUILD_NUMBER]}") unless is_ci | |
end | |
private_lane :build do | |
require_envs(:APP_IDENTIFIER, :GYM_SCHEME, :GYM_WORKSPACE, verbose: true) | |
get_signing_identity() | |
xcargs = { | |
:CODE_SIGN_STYLE => "Manual", #disable automatic signing | |
:PROVISIONING_PROFILE_SPECIFIER => lane_context[:SIGH_NAME], | |
:DEVELOPMENT_TEAM => ENV['TEAM_ID'] | |
} | |
build_ios_app(xcargs: xcargs, output_directory: "build") | |
verify_build(bundle_identifier: ENV['APP_IDENTIFIER'], | |
provisioning_uuid: ENV['SIGH_UUID']) | |
end | |
desc "Run tests with coverage" | |
lane :test do | |
require_envs(:APP_IDENTIFIER, :GYM_SCHEME, :GYM_WORKSPACE) | |
scan(scheme: ENV['GYM_SCHEME'], code_coverage: true, output_directory: "build") | |
end | |
desc "Tags current HEAD for future release" | |
lane :tag_for_release do | |
set_build_number() | |
add_git_tag(tag: "#{get_version_number}-#{lane_context[:build_number]}") | |
end | |
desc "Updates app with a deterministic build number" | |
private_lane :set_build_number do | |
lane_context[:BUILD_NUMBER] = number_of_commits | |
system("cd .. && agvtool new-version -all #{lane_context[:BUILD_NUMBER]}") | |
end | |
desc "Checks HEAD is tagged for release" | |
private_lane :verify_release do | |
head_info = sh("git describe --exact-match HEAD").strip | |
version_tag = "#{get_version_number}-#{lane_context[:BUILD_NUMBER]}" | |
UI.user_error! "HEAD (#{head_info}) not tagged #{version_tag}" unless head_info == version_tag | |
end | |
desc "Get or create signing data (certificate + provisioning profile)." | |
private_lane :get_signing_identity do | |
unlock_keychain() unless ENV["FL_UNLOCK_KEYCHAIN_PASSWORD"].nil? | |
get_certificates(development: ENV["SIGH_DEVELOPMENT"]) | |
get_provisioning_profile(output_path: "build") | |
end | |
private_lane :set_optional_envs do | |
ENV["SIGH_DEVELOPMENT"] ||= ["app-store", "enterprise"].contains(ENV["GYM_EXPORT_METHOD"]) ? false : true | |
end | |
end | |
def require_options(options, names, verbose: false) | |
#using Array(xx) allows to pass an array or a single value to func | |
Array(names).each do |option| | |
UI.user_error!("#{option.downcase} must be specified") if options[option].nil? | |
UI.important "Running with option #{option.downcase} = #{options[option]}" if verbose | |
end | |
end | |
def require_envs(*options, verbose: false) | |
options.each do |option| | |
UI.user_error!("ENV[#{option.downcase}] must be defined") if ENV[option.to_s].nil? | |
UI.important "Running with ENV #{option.downcase} = #{ENV[option.to_s]}" if verbose | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to use it
import("./path/to/other/Fastfile")
into your project Fasftileimport_from_git(url: "")
into your project FasftileYou can then override any pre-defined lane if you need some specific customization.