# 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 beta build to TestFlight"
  lane :beta do |options|
    UI.user_error!("No wssecret given") unless options[:wssecret]
    sh "flutter build ipa -v --obfuscate --split-debug-info=./split-debug-info --dart-define=LICHESS_HOST=https://lichess.org --dart-define=LICHESS_WS_HOST=wss://socket.lichess.org --dart-define=LICHESS_WS_SECRET=#{options[:wssecret]}"
    increment_build_number(
      build_number: latest_testflight_build_number + 1,
      xcodeproj: "Runner.xcodeproj"
    )
    build_app(
      scheme: "Runner",
      skip_build_archive: true,
      archive_path: "../build/ios/archive/Runner.xcarchive",
    )
    upload_to_testflight(api_key_path: "fastlane/app-store-key.json", skip_waiting_for_build_processing: true)
  end
end
