Lane: setup_deployment

Description

This lane can import certificate from input file into a keychain and unlock a keychain.

Available

fastlane_configurations ~> 1.0.0

Overview

lane :setup_deployment do |options|

    xcode_version = options[:xcode_version]

    xcversion(version: "#{xcode_version}") unless xcode_version.nil?

    if is_ci

      reset_git_repo(
       force: true,
       disregard_gitignore: false
      )

      keychain_password = options[:keychain_password] || ENV['KEYCHAIN_PASSWORD']

      certificate_subpath = options[:google_drive_certificate_subpath]
      certificate_path = "#{ENV['HOME']}/Google\ Drive/Mind\ Studios/iOS\ Unit/Certificates/#{certificate_subpath}"
      certificate_password = options[:certificate_password] || ''

      import_certificate(
        keychain_name: "login.keychain-db",
        keychain_password: keychain_password,
        certificate_path: certificate_path,
        certificate_password: certificate_password
      ) unless certificate_subpath.nil?
    end

    unlock_keychain(
      path: "#{ENV['HOME']}/Library/Keychains/login.keychain-db",
      password: keychain_password
    )

  end
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

Usage

Update your Fastfile to contain the following code:

    setup_deployment(
        google_drive_certificate_subpath: "FitCheck/FitCheck_Distribution.p12"
     )
1
2
3

Lane Parameters

KeyDescription
xcode_versionThe version of Xcode to select specified as a Gem::Version requirement string (e.g. '~> 7.1.0')
keychain_passwordThe password for the keychain. Note that for the login keychain this is your user's password. Defaults to CI ENV vars: ENV['KEYCHAIN_PASSWORD']
google_drive_certificate_subpathSubpath to certificate
certificate_passwordCertificate password

Notes