fastlane_version "2.162.0"
default_platform :ios

before_all do
  if is_ci
    setup_ci()
  end
end

desc "Installs all Certs and Profiles necessary for development and ad-hoc"
lane :match_me do
  match(
    type: "adhoc",
    app_identifier: [
        "io.getstream.flutter",
        "io.getstream.flutter.Notifications"
    ],
    readonly: is_ci,
    force_for_new_devices: true
  )
end

platform :ios do
    desc "Deploy build to Firebase"
    lane :deploy_to_firebase do
        match_me

        gym(
            workspace: "./Runner.xcworkspace",
            scheme: "Runner",
            export_method: "ad-hoc",
            export_options: "./fastlane/beta_gym_export_options.plist",
            silent: true,
            clean: true,
            include_symbols: true,
            output_directory: "./dist"
        )

        message = changelog_from_git_commits(commits_count: 10)

        firebase_app_distribution(
            app: "1:674907137625:ios:cafb9fb076a453c4d7f348",
            groups: "ios-stream-testers"
        )
    end
end