从 Fastlane 中的通用平台导入和调用特定平台的通道
Posted
技术标签:
【中文标题】从 Fastlane 中的通用平台导入和调用特定平台的通道【英文标题】:Importing and calling platform-specific lanes from general platform in Fastlane 【发布时间】:2016-06-28 20:13:08 【问题描述】:我有一个 react-native
应用程序,ios
和 android
目录都在一个公共目录中。
我希望能够独立发布(执行通道)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
【问题讨论】:
【参考方案1】:这不是理想的解决方案,因为它最终将您的通道执行包装在另一个通道中,但我们在您的 release_all
中执行此操作,但我想知道它是否允许并行运行:
sh "fastlane ios beta"
sh "fastlane android beta"
【讨论】:
很好的解决方法!我想知道最近的 Fastlane 更新是否能够正确启用它 这不是最好的解决方案,因为当使用 2FA 时,您的通道将挂起,因为它在非交互模式下运行。不幸的是,我没有解决方案,而是使用单个 Fastfile。 @LukeBrandonFarrell 答案是让您的 AppleStore 帐户管理员或帐户持有人为您创建一个 api 密钥。 Google 有类似的解决方案。 是的,有道理。一个键可以得到大约 2FA !【参考方案2】:像这样:
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
这里有一些额外的东西:
yarn 工作区以促进 monorepo the ruby config gem 提供比 dotenv 更好的东西【讨论】:
以上是关于从 Fastlane 中的通用平台导入和调用特定平台的通道的主要内容,如果未能解决你的问题,请参考以下文章