default_platform(:android)

platform :android do
  desc "Sube el AAB actual al track internal de Google Play"
  lane :upload_internal do
    json_key_path = ENV["PLAY_JSON_KEY_PATH"]
    aab_path = ENV["PLAY_AAB_PATH"] || "build/app/outputs/bundle/release/app-release.aab"
    package_name = ENV["PLAY_PACKAGE_NAME"] || "es.freetimelab.pluriwave"

    UI.user_error!("Falta PLAY_JSON_KEY_PATH") if json_key_path.to_s.empty?
    UI.user_error!("No existe el AAB en #{aab_path}") unless File.exist?(aab_path)

    upload_to_play_store(
      json_key: json_key_path,
      package_name: package_name,
      aab: aab_path,
      track: ENV["PLAY_TRACK"] || "internal",
      release_status: ENV["PLAY_RELEASE_STATUS"] || "completed",
      skip_upload_metadata: true,
      skip_upload_images: true,
      skip_upload_screenshots: true,
      skip_upload_changelogs: true
    )
  end
end
