Skip to content
Snippets Groups Projects
Fastfile 2.29 KiB
update_fastlane
default_platform(:ios)

app_name                    = 'client-ios'
xcodeproj                   = app_name+'.xcodeproj'
workspace                   = app_name+'.xcworkspace'

username                    = ENV["USERNAME"]
team_id                     = ENV["TEAM_ID"]

git_url                     = ENV["GIT_URL"]
slack_url                   = ENV["SLACK_URL"]

lane :test do |options|
  clear_derived_data
  scan(
    workspace: workspace,
    scheme: options[:scheme],
    clean: true,
    skip_slack: true,
    code_coverage: true,
    verbose: true
  )
end

lane :archive do |options|
  clear_derived_data
  avoid_2FA

  sign(
    scheme: options[:scheme],
    app_id: options[:app_id],
    notifications_app_id: options[:notifications_app_id]
  )

  gym(
    scheme: options[:scheme],
    workspace: workspace,
    export_method: options[:gym_method],
    clean: true,
    output_name: options[:scheme]+'.ipa',
    export_team_id: team_id,
    verbose: true
  )
end

lane :deploy do |options|
  avoid_2FA

  changelog_from_git_commits(
    pretty: '- (%ae) %s',
    date_format: 'short',
    match_lightweight_tag: false,
    merge_commit_filtering: 'exclude_merges'
  )

  upload_to_testflight(skip_waiting_for_build_processing: true)

  build = number_of_commits(all: true).to_s
  version = get_version_number(xcodeproj: './App/'+xcodeproj, target: app_name).to_s

  slack(
    message: 'iOS '+options[:scheme]+' '+version+' ('+build+') 🚀',
    slack_url: slack_url,
    default_payloads: [],
    use_webhook_configured_username_and_icon: true,
    fail_on_error: false,
    success: true,
    link_names: true
  )
end

lane :sign do |options|
  match(type: options[:method], git_url: git_url, app_identifier: options[:app_id], verbose: true)
  match(type: options[:method], git_url: git_url, app_identifier: options[:notifications_app_id], verbose: true)

  cert(development: options[:method] == 'development', username: username)
  sigh(development: options[:method] == 'development', app_identifier: options[:app_id])
  sigh(development: options[:method] == 'development', app_identifier: options[:notifications_app_id])
end

lane :avoid_2FA do
  app_store_connect_api_key(
    key_id: ENV["KEY_ID"],
    issuer_id: ENV["ISSUER_ID"],
    key_filepath: ENV["KEY_FILEPATH"],
    duration: 1200,
    in_house: false
  )
end