fastlane/Fastfile
# This file contains the fastlane.tools configuration# You can find the documentation at https://docs.fastlane.tools## For a list of all available actions, check out## https://docs.fastlane.tools/actions## For a list of all available plugins, check out## https://docs.fastlane.tools/plugins/available-plugins# # Uncomment the line if you want fastlane to automatically update itself# update_fastlane skip_docs default_platform(:ios) # CONFIG VARIABLESapp_name = 'ios-base'team_id = ENV["APPLE_TEAM_ID"] # The organization's team id in the Apple Developer portalcert = ENV["APPLE_CERT"] # Local path to distribution certificate file to be used for signing the buildkey = ENV["APPLE_KEY"] # Private key (.p12 file) used for encrypting certificatekey_pwd = ENV["APPLE_KEY_PASSWORD"] # Password to private key fileappstore_key_id = ENV["APP_STORE_CONNECT_API_KEY_KEY_ID"] # AppStore Connect API id and issuerappstore_issuer_id = ENV["APP_STORE_CONNECT_API_KEY_ISSUER_ID"] #appstore_key_filepath = ENV["APP_STORE_CONNECT_API_KEY_FILE"] # location of .p8 API key file # S3s3_key = ENV["AWS_ACCESS_KEY_ID"] # credentials for uploading files to S3s3_secret_key = ENV["AWS_SECRET_ACCESS_KEY"] #s3_region = ENV["AWS_REGION"] #s3_bucket = ENV["BUILDS_BUCKET"] # S3 bucket and parent folder to upload tofolder = ENV["FOLDER"] # # Slackslack_channel = ENV["SLACK_CHANNEL"] # Slack webhook url and channel name for sending notifications upon completionslack_url = ENV["SLACK_URL"] # platform :ios do lane :set_signing do # Create keychain - (Travis setup works for GitHhub Actions too) setup_ci( force: true, provider: "travis" ) # Unlock keychain and set as default unlock_keychain( path: "fastlane_tmp_keychain", password: "", set_default: true ) # Import .cer and .p12 - this is a workaround for fastlane match when we retrieve certs from a custom location import_certificate( certificate_path: key, certificate_password: key_pwd, keychain_name: "fastlane_tmp_keychain", keychain_password: "", log_output: true ) import_certificate( certificate_path: cert, keychain_name: "fastlane_tmp_keychain", keychain_password: "", log_output: true ) end lane :build_and_sign do |options| set_signing # pod install cocoapods gym( scheme: options[:scheme], workspace: app_name+'.xcworkspace', export_method: options[:method], export_options: {iCloudContainerEnvironment: 'Production'}, clean: true, include_bitcode: true, output_name: options[:scheme]+".ipa" ) end lane :publish_appstore do |options| # get timestamp datetime = sh("date +%Y%m%d%H%M").chomp # get branch name branch = git_branch() # get app version version = get_version_number(target: options[:scheme]) changelog_from_git_commits( pretty: "- (%ae) %s",# Optional, lets you provide a custom format to apply to each commit when generating the changelog text date_format: "short",# Optional, lets you provide an additional date format to dates within the pretty-formatted string match_lightweight_tag: false, # Optional, lets you ignore lightweight (non-annotated) tags when searching for the last tag merge_commit_filtering: "exclude_merges" # Optional, lets you filter out merge commits ) # Load an App Store Connect API token api_key = app_store_connect_api_key( key_id: appstore_key_id, issuer_id: appstore_issuer_id, key_filepath: appstore_key_filepath, in_house: false # determines this is an AppStore team ) # Submit to TestFlight with the previous token upload_to_testflight( api_key: api_key, skip_waiting_for_build_processing: true ) # send Slack notification - optional slack( message: "Hi! A new iOS "+options[:scheme]+" build has been submitted to TestFlight", payload: { "Build Date" => Time.new.to_s, "Release Version" => version }, channel: slack_channel, slack_url: slack_url, use_webhook_configured_username_and_icon: true, fail_on_error: false, success: true ) end lane :publish_s3 do |options| # get timestamp datetime = sh("date +%Y%m%d%H%M").chomp # get branch name branch = git_branch() # get app version version = get_version_number(target: options[:scheme]) # push to S3 s3_path = folder+"/ios/"+branch+"/"+version+"-"+datetime+"/" aws_s3( access_key: s3_key, secret_access_key: s3_secret_key, bucket: s3_bucket, region: s3_region, ipa: lane_context[SharedValues::IPA_OUTPUT_PATH], path: s3_path, acl: "public-read", upload_metadata: true ) # send notification slack( message: "Hi! A new iOS build has been uploaded for "+options[:scheme], payload: { "Build Date" => Time.new.to_s, "Release Version" => version, "Location" => lane_context[SharedValues::S3_FOLDER_OUTPUT_PATH], "Download link" => "https://"+s3_bucket+".s3.amazonaws.com/"+s3_path+options[:scheme]+".ipa" }, channel: slack_channel, slack_url: slack_url, use_webhook_configured_username_and_icon: true, fail_on_error: false, success: true ) end #DEVELOP lane :build_develop do build_and_sign( scheme: app_name+'-develop', method: 'ad-hoc' ) end lane :share_develop do build_and_sign( scheme: app_name+'-develop', method: 'ad-hoc' ) publish_s3( scheme: app_name+'-develop' ) end lane :release_develop do build_and_sign( scheme: app_name+'-develop', method: 'app-store' ) publish_appstore( scheme: app_name+'-develop' ) end #STAGING lane :build_staging do build_and_sign( scheme: app_name+'-staging', method: 'ad-hoc' ) end lane :share_staging do build_and_sign( scheme: app_name+'-staging', method: 'ad-hoc' ) publish_s3( scheme: app_name+'-staging' ) end lane :release_staging do build_and_sign( scheme: app_name+'-staging', method: 'app-store' ) publish_appstore( scheme: app_name+'-staging' ) end #PRODUCTION lane :build_production do build_and_sign( scheme: app_name+'-production', method: 'ad-hoc' ) end lane :share_production do build_and_sign( scheme: app_name+'-production', method: 'ad-hoc' ) publish_s3( scheme: app_name+'-production' ) end lane :release_production do build_and_sign( scheme: app_name+'-production', method: 'app-store' ) publish_appstore( scheme: app_name+'-production' ) endend