从 Fastlane 中的通用平台导入和调用特定于平台的通道

Importing and calling platform-specific lanes from general platform in Fastlane

我有一个 react-native 应用程序,iosandroid 目录都位于一个公共目录中。 我希望能够独立发布(执行一条车道)iOS 或 Android,所以我在每个平台目录中设置 fastlane init(每个目录创建两个 fastlane/Fastfile平台目录)。 Android Fastfile 大致包含:

platform :android do
  lane: release_android do
    ...
  end

AND iOS:

platform :ios do
  lane: release_ios do
    ...
  end

现在我还在公共目录中手动创建了一个 fastlane/Fastfile 文件,如下所示:

import '../ios/fastlane/Fastfile'
import '../android/fastlane/Fastfile'

lane :release_all do
  release_android
  release_ios
end

但是,当我从主目录 运行 fastlane release_all 时,它会中断 Could not find action or lane 'release_android'

知道我做错了什么吗?难道不能从通用通道调用平台专用通道吗?

环境

快车道 1.96.0

这不是理想的解决方案,因为它最终会将您的车道执行包装在另一条车道上,但我们这样做相当于 release_all,但我想知道它是否允许 运行 这些并行:

sh "fastlane ios beta"
sh "fastlane android beta"

像这样:

package.json

packages/fastlane/
  Fastfile
  config.yml

apps/someapp/
  package.json
  ios/
  android/
  app/
    App.tsx
    App.test.tsx
  fastlane/
    Fastfile
    config.yml

package.json

{
  "name": "yourmonorepo",
  "version": "0.0.1",
  "workspaces": [
    "apps/*",
    "packages/*"
  ],
  "scripts": {
    "app:someapp": "yarn workspace @you/someapp",
    ...
  }
}

packages/fastlane/config.yml

codesigning:
  git_url: git+ssh://git@your.vcs/reponame.git
  branch: master

packages/fastlane/Fastfile

fastlane_require 'config'

# this ends up always being `packages/fastlane`
HERE_DIR = File.expand_path(__dir__)
# different per app, but in the case of `someapp` it'll be `apps/someapp`
APP_ROOT = File.expand_path(File.dirname(Dir.pwd))
# the root of the repo, where your root package.json is
REPO_ROOT = File.expand_path('../..', __dir__)
STAGE_DEV = "development"
STAGE_PROD = "production"

Config.setup do |config|
    config.use_env = true
    config.env_prefix = 'YOU_FASTLANE'
    config.env_separator = '__'
    config.env_converter = :downcase
    config.env_parse_values = true
end

Settings = Config.load_files(
    "#{__dir__}/config.yml",
    "#{Dir.pwd}/config.yml"
)

APPLICATION_ID = Settings.application.id
CRYPTEX_GITURL = Settings.codesigning.git_url
CRYPTEX_BRANCH = Settings.codesigning.branch

lane :setup do
  Fastlane::LaneManager.cruise_lane(
    'ios',
    'keyfile_get',
    {
      'stage' => STAGE_DEV
    }
  )
  Fastlane::LaneManager.cruise_lane(
    'ios',
    'keystore_get',
    {
      'stage' => STAGE_DEV
    }
  )
  Fastlane::LaneManager.cruise_lane(
    'android',
    'keyfile_get',
    {
      'stage' => STAGE_DEV
    }
  )
  Fastlane::LaneManager.cruise_lane(
    'android',
    'keystore_get',
    {
      'stage' => STAGE_DEV
    }
  )
end

platform :android do
  lane :keystore_get do |options|
    stage = options[:stage] || STAGE_DEV
    UI.message("Fetched android #{stage} keystore from codesigning repo #{CRYPTEX_REPO}")
  end

  lane :keyfile_get do |options|
    stage = options[:stage] || STAGE_DEV
    UI.message("Fetched android #{stage} keyfile from codesigning repo #{CRYPTEX_REPO}")
  end

  lane :release_prod do
    # do magic here
  end
end

platform :ios do
  lane :keystore_get do |options|
    stage = options[:stage] || STAGE_DEV
    UI.message("Fetched ios #{stage} keystore from codesigning repo #{CRYPTEX_REPO}")
  end

  lane :keyfile_get do |options|
    stage = options[:stage] || STAGE_DEV
    UI.message("Fetched ios #{stage} keyfile from codesigning repo #{CRYPTEX_REPO}")
  end

  lane :release_prod do
    # do magic here
  end
end

apps/someapp/package.json

{
  "name": "@you/someapp",
  "version": "0.0.1",
  "scripts": {
    "fastlane": "fastlane"
  }
}

apps/someapp/fastlane/config.yml

application:
  id: com.you.someapp

apps/someapp/fastlane/Fastfile

$VERBOSE = nil

import '../../../packages/fastlane/Fastfile'

现在你可以 运行 :

yarn app:someapp fastlane setup

yarn app:someapp fastlane ios keystore_get stage:'development'
yarn app:someapp fastlane android keystore_get stage:'development'

您甚至可以在 CI 中执行 :

YOU_FASTLANE__CODESIGNING__GIT_URL=https://github.com/your/repo.git \
  yarn app:someapp fastlane ios release_prod
YOU_FASTLANE__CODESIGNING__GIT_URL=https://github.com/your/repo.git \
  yarn app:someapp fastlane android release_prod

这里有一些额外内容: