default_platform(:ios)

# Credentials via `pass`
# export FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD=$(pass show appstore/apple-app-specific-password)

platform :ios do
  EXPORT_OPTIONS = {
    method: "app-store",
    signingStyle: "manual",
    manageAppVersionAndBuildNumber: false,
    provisioningProfiles: {
      "com.alexandrevazquez.PortfolioJournal" => "porfoliojournal",
      "com.alexandrevazquez.PortfolioJournal.PortfolioJournalWidget" => "Portfolio Journalwidget"
    }
  }

  desc "Upload metadata and release notes only (binary already uploaded)"
  lane :metadata do
    deliver(
      metadata_path: "fastlane/metadata",
      skip_screenshots: true,
      skip_binary_upload: true,
      force: true
    )
  end

  desc "Push a new beta build to TestFlight"
  lane :beta do
    build_app(
      scheme: "PortfolioJournal",
      export_options: EXPORT_OPTIONS
    )
    upload_to_testflight(skip_waiting_for_build_processing: true)
  end

  desc "Build, export and push a new release to the App Store"
  lane :release do
    build_app(
      scheme: "PortfolioJournal",
      export_options: EXPORT_OPTIONS
    )
    upload_to_app_store(
      metadata_path: "fastlane/metadata",
      skip_screenshots: true,
      force: true
    )
  end
end
