# 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
  lane :matchAppStore do
    match(
      type: "appstore",
      api_key_path: "app_store_api_key.json",
      app_identifier: "io.github.lydavid.musicsearch",
      team_id: "29HRCHW674",
      git_url: is_ci ? "https://github.com/lydavid/musicsearch-fastlane-match.git" : "git@github.com:lydavid/musicsearch-fastlane-match.git",
      readonly: is_ci
    )
  end

  lane :publish do |options|
    setup_ci if ENV['CI']
    matchAppStore
    build_app(
      project: "ios-app/musicsearch.xcodeproj",
      scheme: "Release",
      export_options: {
        "signingStyle": "automatic"
      },
      xcargs: "-allowProvisioningUpdates",
      clean: true
    )
    upload_to_app_store(
      api_key_path: "app_store_api_key.json",
      metadata_path: "fastlane/metadata/ios",
      force: true,
      submit_for_review: false,
      automatic_release: true,
      phased_release: true,
      precheck_include_in_app_purchases: false
    )
  end
end
