default_platform(:android)

platform :android do
  desc "Build App Bundle"
  lane :build_aab do |options|
    sh(
      "flutter",
      "build",
      "appbundle",
      "--release",
      "--bundle-sksl-path=shaders/android_sksl.json",
      "--build-number=#{options[:build_number]}",
    )

    sh("mkdir", "-p", "../../output")
    sh("mv", "../../build/app/outputs/bundle/release/app-release.aab", "../../output/lunasea-android.aab")
  end

  desc "Build APK"
  lane :build_apk do |options|
    sh(
      "flutter",
      "build",
      "apk",
      "--release",
      "--bundle-sksl-path=shaders/android_sksl.json",
      "--build-number=#{options[:build_number]}",
    )

    sh("mkdir", "-p", "../../output")
    sh("mv", "../../build/app/outputs/flutter-apk/app-release.apk", "../../output/lunasea-android.apk")
  end

  desc "Deploy to Google Play Store"
  lane :deploy_playstore do |options|
    upload_to_play_store(
      aab: options[:aab],
      skip_upload_metadata: true,
      skip_upload_images: true,
      skip_upload_screenshots: true,
      track: options[:track],
      version_name: options[:version_name],
    )
  end
end
