# 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

default_platform(:ios)

platform :ios do
  desc 'Push a new release build to the App Store'
  lane :release do
    # Setup for CI. Uses a keychain to prevent the CI from hanging due to password prompts.
    setup_ci

    # Obtain credentials from App Store Connect API. Will be automatically used for the rest of the lane.
    app_store_connect_api_key(
      key_id: ENV['APP_STORE_KEY_ID'],
      issuer_id: ENV['APP_STORE_ISSUER_ID'],
      key_content: ENV['APP_STORE_CREDENTIALS'],
      is_key_content_base64: true,
    )

    # Manage code signing (with match).
    sync_code_signing

    # Build the app for release.
    build_app(
      workspace: 'Runner.xcworkspace',
      scheme: 'Runner',
      output_directory: '../build/ios/archive'
    )

    # Upload the app to the App Store.
    upload_to_app_store(
      submit_for_review: true,
    )
  end
end
