require_relative 'lib/helper/cocoapods_helper'
require_relative 'lib/helper/version_helper'

fastlane_version "2.69.0"

lane :prepare_pods do
  # This helps optimize CI with caching by testing whether a pod install is necessary
  # from cocoapods_helper
  pod_install_if_required '../Branch-TestBed'
  # Can also turn on verbose output and disable repo update
  # pod_install_if_required '../Branch-TestBed', verbose: true, repo_update: false
end

lane :unit_tests do
  prepare_pods
  # This testplan only runs unit tests for PR verification.
  scan scheme: 'Branch-TestBed-CI'
end

lane :integration_tests do
  prepare_pods
  # This testplan includes unit tests as well as integration tests.
  scan scheme: 'Branch-TestBed'
end

# bundle exec fastlane version_bump version:patch # default
# bundle exec fastlane version_bump version:minor
# bundle exec fastlane version_bump version:major
# bundle exec fastlane version_bump version:1.41.0
lane :version_bump do |opts|
  # from version_helper
  next_version = update_sdk_version opts
  sh 'git', 'commit', '-a', '-m', "[release] #{next_version}"
end

lane :current_version do
  UI.message 'Generating fastlane/.version with podspec version'
  File.open('.version', 'w') do |f|
    f.puts current_pod_version
  end
end
