platform :ios do
    lane :release do
        setup_ci

        match(
            type: "appstore",
            app_identifier: ENV["APPLE_APP_IDENTIFIER"],
            git_url: ENV["MATCH_GIT_URL"]
        )

        update_project_team(
            path: "ios/Runner.xcodeproj",
            teamid: ENV["APPLE_TEAM_ID"]
        )

        update_project_provisioning(
            xcodeproj: "ios/Runner.xcodeproj",
            profile: ENV["sigh_#{ENV["APPLE_APP_IDENTIFIER"]}_appstore_profile-path"],
            build_configuration: "Release",
            code_signing_identity: "iPhone Distribution"
        )

        build_app(
            workspace: "ios/Runner.xcworkspace",
            scheme: "Runner"
        )

        upload_to_app_store(
            force: true,
            username: ENV["APPLE_USERNAME"],
            overwrite_screenshots: true,
            submit_for_review: true,
            automatic_release: true,
            submission_information: {
                add_id_info_serves_ads: false,
                add_id_info_tracks_action: false,
                add_id_info_tracks_install: false,
                add_id_info_uses_idfa: false,

                content_rights_contains_third_party_content: false,
                content_rights_has_rights: false,

                export_compliance_platform: 'ios',
                export_compliance_compliance_required: false,
                export_compliance_encryption_updated: false,
                export_compliance_app_type: nil,
                export_compliance_uses_encryption: false,
                export_compliance_is_exempt: false,
                export_compliance_contains_third_party_cryptography: false,
                export_compliance_contains_proprietary_cryptography: false,
                export_compliance_available_on_french_store: false
            }
        )
    end
end
