Action
#fastlane
概要
fastlane は、事前に用意された Action を組み合わせることで、モバイル開発における様々なタスクを簡潔に記述、実行できるようになっている。
現在利用可能な Action は下記のコマンドで確認することもできるし、
code:bash
# 利用可能な全てのコマンドを出力する
fastlane actions
# 特定のアクションの情報を出力する
fastlane action action名
下記の doc でも確認できる。
https://docs.fastlane.tools/actions/
主な Action としては以下のようなものがある。
table:actions
アクション名 概要
scan iOS/macOSアプリのテストを実行する
gym iOS/macOSアプリをビルドする
snapshot スクショを撮影する (fastlane snapshot)
match 証明書等を管理する (fastlane match)
pilot アプリを TestFlight へアップロードする
deliver アプリを AppStore へアップロードする
cocoapods pod install を実行する
Option
Action にはその実行に必要なオプションを受け渡すことができる。どのようなオプションが利用可能か?については fastlane action [action名] などでチェックできる。
オプションを指定する方法はいくつかあり、以下の優先度で採用される。
1. CLI の引数 (gym --scheme Example) もしくは Fastfile 上の指定 (gym(scheme: 'Example'))
2. 環境変数 (GYM_SCHEME)
3. 専用の設定ファイル (Gymfile 内の scheme 'Example')
4. デフォルト値 (gym の scheme であれば、Appfile 内の app_identifier になる)
5. 値が必須である場合は、fastlane から値を尋ねられる
https://docs.fastlane.tools/advanced/fastlane/#priorities-of-parameters-and-options
Action 間で値を共有する
1 つの lane 実行には複数の action が関わってくることが多い。この時、lane 実行中に action 間で共有の値を参照したい という要求があるかもしれない。このような場合に lane_context という Action が利用できる。
https://docs.fastlane.tools/advanced/lanes/#lane-context
lane_context は、組み込みの Action にて出力値を格納するのに利用されている。例えば、ビルドの実行を行う Action である gym の doc をみると、下記の 4 つが lane variables として記載されている。これらは、lane 内の別の action から lane_context[SharedValue名] で参照できるようになっている。
table:lane_variables
SharedValue Description
SharedValues::IPA_OUTPUT_PATH The path to the newly generated ipa file
SharedValues::PKG_OUTPUT_PATH The path to the newly generated pkg file
SharedValues::DSYM_OUTPUT_PATH The path to the dSYM files
SharedValues::XCODEBUILD_ARCHIVE The path to the xcodebuild archive
カスタムアクションの作成
https://docs.fastlane.tools/create-action/
Git 関連のヘルパーアクションは牡蠣に色々揃っている
https://github.com/fastlane/fastlane/blob/48151291f2c4949c3b1b9919ba2cc81a7cc33293/fastlane/lib/fastlane/helper/git_helper.rb