# Customise this file, documentation can be found here:
# https://github.com/fastlane/fastlane/tree/master/fastlane/docs
# All available actions: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Actions.md
# can also be listed using the `fastlane actions` command

# Change the syntax highlighting to Ruby
# All lines starting with a # are ignored when running `fastlane`

# If you want to automatically update fastlane if a new version is available:
# update_fastlane

# This is the minimum version number required.
# Update this, if you use features of a newer version
fastlane_version "2.68.0"

default_platform :ios

platform :ios do
  desc "Runs all the tests"
  lane :test do
    scan
  end

  desc "Test build without packaging"
  lane :build do
    unlock_keychain
    match(
      force: true,
      type: "development"
    )
    gym(
      scheme: "Ring",
      clean: true,
      configuration: "Development",
      export_method: 'development',
      skip_package_ipa: true
    )
  end

  desc "Submit a new Beta Build to Apple TestFlight"
  lane :beta do
    ensure_git_status_clean
    unlock_keychain
    match(
      type: "appstore"
    )
    increment_build_number
    gym(
      scheme: "Ring",
      clean: true,
      configuration: "Release",
      export_method: 'app-store',
    )
    pilot(
      skip_waiting_for_build_processing: true
    )
    new_build_number = Actions.lane_context[Actions::SharedValues::BUILD_NUMBER]
    current_version = get_version_number
    message = "project: bump to version #{current_version}.#{new_build_number} for release"
    clean_build_artifacts
    commit_version_bump(
      xcodeproj: "Ring.xcodeproj",
      message: message,
      force: true
    )
  end

  after_all do |lane|
    # This block is called, only if the executed lane was successful
  end

  error do |lane, exception|
    # This block is called, only if the executed lane has failed
  end
end
