7

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

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

和 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

4

2 回答 2

3

这不是理想的解决方案,因为它最终将您的通道执行包装在另一个通道中,但我们在您的等效项中执行此操作release_all,但是我想知道它是否允许并行运行它们:

sh "fastlane ios beta"
sh "fastlane android beta"
于 2016-10-17T21:22:59.223 回答
0

像这样:

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

这里有一些额外的东西:

  • 纱线工作区以促进 monorepo
  • ruby config gem提供比 dotenv 更好的东西
于 2021-02-27T03:46:30.900 回答