bandit-the-cat-ios-fastlane-example

A sample about about Bandit The Cat using fastlane - http://fastlane.tools/

3 years after

fastlane example with Bandit The Cat

My Additions

  • Gemfile
    • Manage all my lane dependencies - dotenv, Shenzen, AWS, etc.
  • fastlane/.env
    • Allows me to store varialbes in a .env file
    • None of my credential or API keys are sitting in the lane logic
    • Makes reusing my lanes in other projects easier (only need a new .env)
    • I can include .env in my .gitignore file so no one else has my credentials

Fastlane

  • Fastfile - define your lanes (test, beta, deploy, inhouse, etc.)
  • actions - create custom actions for your lanes (upload to S3, upload through FTP, send a text through Twilio, etc.)

Snapshot

  • Used to take screenshots across all/any devices
  • Snapfile - define your snapshot configurations
  • snapsho.js - define the steps using UI Automation to run through your app and take screenshots at certain points
  • SnapshowHelper.js - helpers for your UI Automation
  • screenshots - the output directory for you screenshots

Deliver

  • Used to send builds (TestFlight, App Store)
  • Deliverfile - define your deliver configurations

My Paths

Before - view here

before_all do
  # Increments build number of your project
  increment_build_number

  # Makes sure all cocoapods are up to date
  cocoapods

  # Runs unit tests
  # - argumnets passed as array of strings
  # - Docs on xctool (https://github.com/facebook/xctool)
  xctool ["-workspace #{ENV['WORKSPACE']}", "-scheme #{ENV['SCHEME']}"]
end

Test - view here

lane :test do
  # Takes all screenshots for you (so magical)
  # - Configurations are in Snapfile
  # - Steps are defined in the snapshot.js
  snapshot
end

Beta - view here

lane :beta do
  # Gets (and renews) provisioning profiles
  sigh

  # Builds IPA
  gym(scheme: ENV['SCHEME'], configuration: 'Inhouse')

  # Send to HockeyApp
  hockey(
    api_token: ENV['HOCKEYAPP_API_TOKEN'],
    notify: 1
  )

end

Deploy - view here

lane :deploy do
  snapshot
  sigh
  gym(scheme: ENV['SCHEME'], configuration: 'Inhouse')
  deliver(force: true)
end

Inhouse - view here

lane :inhouse do
  # sigh
  sigh

  # Builds IPA
  gym(scheme: ENV['SCHEME'], configuration: 'Inhouse')

  upload_to_s3(
    ipa_name: ENV['ipa_name'],
    scheme: ENV['SCHEME'],
    bundle_id: ENV['BUNDLE_ID'],
    s3_bucket: ENV['S3_BUCKET'],
    s3_access_key: ENV['S3_ACCESS_KEY'],
    s3_secret_access_key: ENV['S3_SECRET_ACCESS_KEY']
  )

end

After - view here

after_all do |lane|
  clean_build_artifacts

  # Create message for slack 
  message = nil
  case lane
  when :beta
    build_number = lane_context[Actions::SharedValues::BUILD_NUMBER]

    url = lane_context[Actions::SharedValues::HOCKEY_DOWNLOAD_LINK]
    build_info = lane_context[Actions::SharedValues::HOCKEY_BUILD_INFORMATION]

    message = "Deployed build #{build_number} of #{build_info['title']} to HockeyApp - #{url}"
  when :inhouse
    build_number = get_build_number
    version_number = get_version_number
    version_name = "v#{version_number} (#{build_number})"

    url = Actions.lane_context[ Actions::SharedValues::UPLOAD_TO_S3_URL]
    message = "Deployed build #{version_name} to S3 - #{url}"
  end

  # Sebd nessage to slack
  if message
    slack(
     message: message,
     success: true,
    )
  end

end

Travis

  • Export inhouse.cer and inhouse.p12
  • travis encrypt "KEY_PASSWORD={password}" --add
  • travis encrypt "ENCRYPTION_SECRET={encryption_secret}" --add
  • Encrypt inhouse.cer and inhouse.p12
    openssl aes-256-cbc -k "{encryption_secret}" -in scripts/certs/inhouse.cer -out scripts/certs/inhouse.cer.enc -a
    openssl aes-256-cbc -k "{encryption_secret}" -in scripts/certs/inhouse.p12 -out scripts/certs/inhouse.p12.enc -a

Top Contributors

joshdholtz KrauseFx