fastlane:深ťæµÅVAR。
#android #ios #fastlane

U¿

æ -ç

ç³»Å索ż

  1. Fastlane - iOS 和 Android 的自动化构建工具
  2. 深入浅出 Fastlane 一看你就懂
  3. 你虐我千百遍,我待你如初恋,直到我遇到 match

Ž件èlleÅ·¥Å·

Å£££££15£15× ¥ang ang ang盎司。搜索¶ä»¥Å®çÅ??¼

$ fastlane --help

  fastlane

  CLI for 'fastlane' - The easiest way to automate building and releasing your iOS and Android apps

        Run using `fastlane [platform] [lane_name]`
        To pass values to the lanes use `fastlane [platform] [lane_name] key:value key2:value2`

  Commands:
    action                  Shows more information for a specific command
    actions                 Lists all available fastlane actions
    add_plugin              Add a new plugin to your fastlane setup
    disable_crash_reporting Deprecated: fastlane doesn't use a crash reporter any more
    docs                    Generate a markdown based documentation based on the Fastfile
    enable_auto_complete    Enable tab auto completion
    enable_crash_reporting  Deprecated: fastlane doesn't use a crash reporter any more
    help                    Display global or [command] help documentation
    init                    Helps you with your initial fastlane setup
    install_plugins         Install all plugins for this project
    lanes                   Lists all available lanes and shows their description
    list                    Lists all available lanes without description
    new_action              Create a new custom action for fastlane.
    new_plugin              Create a new plugin that can be used with fastlane
    run                     Run a fastlane one-off action without a full lane
    search_plugins          Search for plugins, search query is optional
    trigger                 Run a sepcific lane. Pass the lane name and optionally the platform first.
    update_plugins          Update all plugin dependencies

  Global Options:
    --verbose
    -h, --help           Display help documentation
    -v, --version        Display version information

  Author:
    Felix Krause <fastlane@krausefx.com>

  Website:
    https://fastlane.tools

  GitHub:
    https://github.com/fastlane/fastlane

ŽÅ

§ee§ee§ <
vi
1 tre_all Å -æ§èt
2 tre_each æ -
3 èªÅ®ä¹
4 after_each æ -
5 after_all Åâ§èt
6 错误 Å® Ƨèâä?走园

ä»ɪ¸ äääääääää电â

ä»»Åï¼Laneï¼

æ矿石£Åšj䈻»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» »»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» »» »» »» »» »» »» »» »» »» »» »» »» »» » lane Ľ Å ¶å® Åq Å amå activity accident activity activity activity activity activity¾ ¤é à 㠨 у у al&�ââμL«freeoqä¼ok |“æ

ä»»»»�®

ÅÅ奥»°函

Å®ääâ <
vi
desc false æ讯 ÅI-¯
名称 true æ讯 ç -Å············
选项 false æ它们Åæ° v
任务 true æ½ Åèrubyçæ
desc '定义一个 build 方法'
desc '参数 adhoc 判断是否为内测版本, 默认为 false'
desc 'fastlane build'
desc 'fastlane build adhoc:true'
lane :build do |options|
  # task to do something
  adhoc = options[:adhoc] || false
  puts "adhoc: #{adhoc}"

  gym(type: adhoc ? 'adhoc' : 'appstore')
end

任ŧèt

äst •ÅÅ了※€®ästä宝石build ±f。

# 默认执行
$ fastlane build
# 传递参数
$ fastlane build adhoc:true

ä»Å亰°

laneÅÅ»¥ç°°koud8讯源ª Éææää»11Å°°±Å¼°É§èmout â€éprivate_lane


default_platform :ios

platform :ios do
  desc '构建前的准备工作'
  desc '这是一个私有任务,仅供 Fastfile 内部 lane 调用使用'
  lane :prepare do
    cocoapods
    match
  end

  desc '通用的构建任务'
  desc 'fastlane build'
  desc 'fastlane build type:adhoc'
  lane :build do |options|
    # 调用上面 prepare 私有任务
    prepare

    case options[:type]
    when 'adhoc'
      # 调用 下面 adhoc 任务
      adhoc
    else
      # 调用下面 appstore 任务
      appstore
    end
  end

  desc '构建 adhoc 任务'
  desc 'fastlane adhoc'
  lane :adhoc do
    gym(type: 'adhoc')
  end

  desc '构建 appstore 任务'
  desc 'fastlane appstore'
  lane :appstore do
    gym(type: 'appstore')
  end
end

䈢ç¢äst Ž仧ä§tout§toutoun§¼§¼'

$ fastlane prepare
[19:17:42]: You can't call the private lane 'prepare' directly

ä»»át

ÅRubyC.lanelaneææ假和¼Ép€½½ä½ä½了。


lane :sum do |options|
  options[:a] + optiona[:b]
end

lane :calculate do
  value = sum(a: 3, b: 5)
  puts value #=> 8
end

Å11至¥Ééâ€â€ää¶

Fastfile is亓äè” ä警¶¶车¶¶¶ ¥ÅF了»»»€¶ä½¶¶¶¶¶扬¶扬¶相S search和â€â€ɪ

1.进口-ż¥æ -€€°ä»¶

# 导入 lanes 目录的 AndroidFastfile
import "lanes/AndroidFastfile"

2. import_from_git-ż¥gitä»ÅVir

ɪ¥¥Åo g u guit£€»»€它们ÅbRITAPR了;物

# 导入 mozilla/firefox-ios 项目下 fastlane 下面 Fastfile 文件
import_from_git(url: 'https://github.com/mozilla/firefox-ios')
# 或者
import_from_git(url: 'git@github.com:mozilla/firefox-ios.git',
               path: 'fastlane/Fastfile')

Å是€€ââ€kountR了<中Δää的¸

$ fastlane ios build

[!] Lane 'gradle' was defined multiple times!

Å°ÅÅÅC。 override_lane

thoutp> ±¶¶¶±±±±±±±±±± - 直接ä¼¼¼€ç±〜K±€³¾¾¼

override_lane :build do
  ...
end

任ť¥ç

ªª€stripoutoutoutout â将

$ fastlane lanes

--------- ios---------
----- fastlane ios build
通用的构建任务
fastlane build
fastlane build type:adhoc

----- fastlane ios adhoc
构建 adhoc 任务

----- fastlane ios appstore
构建 appstore 任务

Execute using `fastlane [lane_name]`

æ©Å±ï¼Actionï¼

lim

±±±±±±±ā u主¸ Åé½æ±±±±±±±。 。

©©Å±Åè

$ fastlane actions
+--------------------+-------------------------------------------------------------+------------------+
|                                   Available fastlane actions                                        |
+--------------------+-------------------------------------------------------------+------------------+
| Action             | Description                                                 | Author           |
+--------------------+-------------------------------------------------------------+------------------+
| adb                | Run ADB Actions                                             | hjanuschka       |
| adb_devices        | Get an Array of Connected android device serials            | hjanuschka       |
| add_git_tag        | This will add an annotated git tag to the current branch    | Multiple         |
...
+--------------------+-------------------------------------------------------------+------------------+
  Total of 175 actions

Get more information for one specific action using `fastlane action [name]`

# 查看 adb 扩展的使用帮助
$ fastlane action adb
Loading documentation for adb:

+---------------------------------+
|               adb               |
+---------------------------------+
| Run ADB Actions                 |
|                                 |
| see adb --help for more details |
|                                 |
| Created by hjanuschka           |
+---------------------------------+

+----------+----------------------------------------------------------------------+-------------------+---------+
|                                                  adb Options                                                  |
+----------+----------------------------------------------------------------------+-------------------+---------+
| Key      | Description                                                          | Env Var           | Default |
+----------+----------------------------------------------------------------------+-------------------+---------+
| serial   | Android serial, which device should be used for this command         | FL_ANDROID_SERIAL |         |
| command  | All commands you want to pass to the adb command, e.g. `kill-server` | FL_ADB_COMMAND    |         |
| adb_path | The path to your `adb` binary                                        | FL_ADB_PATH       | adb     |
+----------+----------------------------------------------------------------------+-------------------+---------+

+-------------------------------+
|       adb Return Value        |
+-------------------------------+
| The output of the adb command |
+-------------------------------+

More information can be found on https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Actions.md

Å媻ªª±±±±

Éè?ÅŽ®çŽ什»°»ºä½É。 Å€€»€â€â€ÅK了。 ç»ï¼ç好CIT

$ fastlane new_action
Must be lower case, and use a '_' between words. Do not use '.'
examples: 'testflight', 'upload_to_s3'
Name of your action: hello
[15:33:15]: Created new action file './fastlane/actions/hello.rb'. Edit it to implement your custom action.

è。

Å11至¥é©©©

ÅÅŶ¶¶项iïgroult¥ı(ı。 -

1.®

andª »¶»¶»¶»¶»¶»威希威希威希»»威希»威希»»实Å®

# 引入项目根目录 script/share_actions 路径
actions_path '../script/share_actions'

2.红宝石ż¥¥

äst

¢â€¢equ¢»°»°»fl ±±±±±beleed€¢É¢ÉjuIdoutouth了¾ â€e 40€¯

# 首先安装需要的 rubygem: gem install fastlane-qyer
require 'fastlane-qyer'

lane :upload do
  qyer(api_key: '[token]')
end
3.件żť Éé¿ -

$ fastlane search_plugins
[16:04:33]: Listing all available fastlane plugins

+--------------------------+---------------------------------------------------+-----------+
|                                Available fastlane plugins                                |
+--------------------------+---------------------------------------------------+-----------+
| Name                     | Description                                       | Downloads |
+--------------------------+---------------------------------------------------+-----------+
| ruby                     | Useful fastlane actions for Ruby projects         | 782       |
| versioning               | Allows to work set/get app version directly       | 758       |
|                          | to/from Info.plist                                |           |
| branding                 | Add some branding to your fastlane output         | 716       |
| instrumented_tests       | New action to run instrumented tests for android. | 590       |
|                          | This basically creates and boots an emulator      |           |
|                          | before running an gradle commands so that you can |           |
|                          | run instrumented tests against that emulator.     |           |
|                          | After the gradle command is executed, the avd     |           |
|                          | gets shut down and deleted. This is really        |           |
|                          | helpful on CI services, keeping them clean and    |           |
|                          | always having a fresh avd for testing.            |           |
| xamarin_build            | Build xamarin android\ios projects                | 582       |
| appicon                  | Generate required icon sizes and iconset from a   | 509       |
|                          | master application icon.                          |           |
...
| download_file            | This action downloads a file from an HTTP/HTTPS   | 171       |
|                          | url (e.g. ZIP file) and puts it in a destination  |           |
|                          | path                                              |           |
+--------------------------+---------------------------------------------------+-----------+

# 添加 sentry 插件
$ fastlane add_plugin sentry
[16:16:23]: Plugin 'fastlane-plugin-sentry' was added to './fastlane/Pluginfile'
[16:16:23]: It looks like fastlane plugins are not yet set up for this project.
[16:16:23]: fastlane will create a new Gemfile at path 'Gemfile'
[16:16:23]: This change is neccessary for fastlane plugins to work
Should fastlane modify the Gemfile at path 'Gemfile' for you? (y/n)
y
[16:16:29]: Successfully modified 'Gemfile'
[16:16:29]: Make sure to commit your Gemfile, Gemfile.lock and Pluginfile to version control
Installing plugin dependencies...
Successfully installed plugins

$ cat fastlane/Pluginfile
# Autogenerated by fastlane
#
# Ensure this file is checked in to source control!

gem 'fastlane-plugin-sentry'

æ´è°ç»ç»§j»Å¾ÅÅÅ °°

ç“ź¶¶¶” ɪSÅésÅ退£QU£QU£QU®CultoThiptourto

# 使用 notification 扩展发送一个通知消息
$ fastlane run notification message:"Hi macOS" title:"Fastlane Notification"
[15:58:05]: --------------------------
[15:58:05]: --- Step: notification ---
[15:58:05]: --------------------------
[15:58:05]: Result: true

è¾Å

èªÅ

fastlaneÆä电ij update_fastlaneK ij€« - - - 项目ÁK了®Cfastlaneat /wöthi¶¶¶¶¶¶ 。

update_fastlane(tools:'fastlane,gym,match,cocoapods,rest-client')

ç -布¢Åé

ääääääääš假<。 ©±±± ^tent。 ¶É¶é¾奥讯

ç -布极 æ¥æº vi
fastlane_user recithentials_manager 苹果żÅ了è。 在
fastlane_password recithentials_manager 苹果żåè。 在
fastlane_team_id
cert_team_id
product
叹气
苹果Å¢ÉID
deliver_user
produce_username
交付
product
itunesConnectè´è·Å
deliver_password 交付 itunesConnectIdinectinectinectine
match_password 匹配 vi
fastlane_xcode_list_timeout fastlane_core è·ÅIOS方案Çè¶æ¶É¶ é»è®20s