Skip to content

Instantly share code, notes, and snippets.

@ugommirikwe
Forked from vbalagovic/Fastfile
Created December 6, 2022 05:18
Show Gist options
  • Save ugommirikwe/f385513030e3a4fd8b03cae10133386a to your computer and use it in GitHub Desktop.
Save ugommirikwe/f385513030e3a4fd8b03cae10133386a to your computer and use it in GitHub Desktop.
#Ruby version
ruby_version("3.0.2")
# Uncomment the line if you want fastlane to automatically update itself
# update_fastlane
fastlane_require 'dotenv'
default_platform(:ios)
platform :ios do
# Have an easy way to get the root of the project
def root_path
Dir.pwd.sub(/.*\Kfastlane/, '').sub(/.*\Kandroid/, '').sub(/.*\Kios/, '').sub(/.*\K\/\//, '')
end
# Have an easy way to run flutter tasks on the root of the project
lane :sh_on_root do |options|
command = options[:command]
sh("cd #{root_path} && #{command}")
end
# Updates XCode project settings to use a different code signing based on method
private_lane :archive do |options|
method = options[:method]
env = ENV['IOS_SCHEME']
scheme = env == "dev" ? "dev" : "prod"
configuration = env == "dev" ? "Release-dev" : "Release-prod"
update_code_signing_settings(
build_configurations: configuration,
use_automatic_signing: true
)
update_project_team(
teamid: ENV['IOS_TEAM_ID']
)
build_app(
output_directory: "#{root_path}/build/ios",
build_path: "#{root_path}/build/ios",
archive_path: "#{root_path}/build/ios",
export_method: method,
scheme: env,
configuration: configuration,
xcargs: "-allowProvisioningUpdates"
)
end
lane :build do |options|
env = ENV['IOS_SCHEME']
params = env == "dev" ? '--flavor dev -t lib/main_dev.dart ' : '--flavor prod -t lib/main_prod.dart '
desc("Cleaning...")
sh_on_root(command: "fvm use #{ENV['FLUTTER_VERSION']} && rm -Rf ios/Pods && rm -Rf ios/.symlinks && rm -Rf ios/Flutter/Flutter.framework && rm -Rf ios/Flutter/Flutter.podspec")
desc("Pod upgrading...")
sh_on_root(command: "fvm use #{ENV['FLUTTER_VERSION']} && cd ios && fvm flutter pub get && fvm flutter precache --ios && pod install --repo-update")
desc("Flutter cleaning ...")
sh_on_root(command: "fvm use #{ENV['FLUTTER_VERSION']} && cd ios && fvm flutter clean")
desc("Building...")
sh_on_root(command: "fvm use #{ENV['FLUTTER_VERSION']} && fvm flutter build ipa #{params}")
end
lane :deploy_staging do
build(sign_enabled: true)
archive(method: "ad-hoc")
firebase_app_distribution(
app: ENV['IOS_FIREBASE_APP_DISTRIBUTION_APP'],
testers: ENV['IOS_FIREBASE_APP_DISTRIBUTION_TESTERS'],
release_notes: ENV['IOS_FIREBASE_APP_DISTRIBUTION_RELEASE_NOTES'],
service_credentials_file: ENV['IOS_FIREBASE_APP_DISTRIBUTION_CREDENTIALS_FILE_PATH'],
)
end
lane :deploy_beta do
build(sign_enabled: true)
archive(method: "app-store")
api_key = app_store_connect_api_key(
key_id: "<KEY_ID>", #for test purposes use direct, but before code deploy use variables as rest from .env.production
issuer_id: "<KEY_ISSUER_ID>",#for test purposes use direct, but before code deploy use variables as rest from .env.production
key_filepath: "<PATH_TO_THE_P8_KEY>",#for test purposes use direct, but before code deploy use variables as rest from .env.production
duration: 1200, # optional (maximum 1200)
in_house: false # optional but may be required if using match/sigh
)
upload_to_testflight(
api_key: api_key,
username: ENV["APP_STORE_CONNECT_USERNAME"]
)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment