# 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(:android)

platform :android do
  desc "Deploy an internal test version to Google Play"
  lane :internal_test do |options|
    UI.user_error!("No wssecret given") unless options[:wssecret]
    sh "flutter build appbundle -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]}"
    upload_to_play_store(
      track: 'internal',
      aab: '../build/app/outputs/bundle/release/app-release.aab',
      release_status: 'draft',
    )
  end
end

platform :android do
  desc "Deploy an closed test version to Google Play"
  lane :alpha do |options|
    UI.user_error!("No wssecret given") unless options[:wssecret]
    sh "flutter build appbundle -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]}"
    upload_to_play_store(
      track: 'alpha',
      aab: '../build/app/outputs/bundle/release/app-release.aab',
    )
  end
end
