Reputation: 17448
I have a react-native
app, with both ios
and android
directories inside a common directory.
I want to be able to release (execute a lane) iOS or Android independently, so I setup fastlane init
in each of the platform dirs (which created two fastlane/Fastfile
in each platform dir).
Android Fastfile
roughly contains:
platform :android do
lane: release_android do
...
end
AND iOS:
platform :ios do
lane: release_ios do
...
end
Now I also manually created a fastlane/Fastfile
file in the common containing dir that looks like this:
import '../ios/fastlane/Fastfile'
import '../android/fastlane/Fastfile'
lane :release_all do
release_android
release_ios
end
However, when I run fastlane release_all
from the main dir, it breaks with Could not find action or lane 'release_android'
.
Any idea what I'm doing wrong here? Could it not be possible to call a platform-specific lane from a general lane?
fastlane 1.96.0
Upvotes: 10
Views: 4418
Reputation: 209
I had the same issue and after some research I found that there was an issue posted to fastlane for this exact scenario.
Instead of calling with the shell, you can use the core fastlane code to switch lanes the same way that fastlane switches lanes.
I'll post the snippet here in case the link dies.
You use the lane manager to switch to another lane, passing whatever platform, lane, params, or even env details to the specified lane.
See the source code here
An example:
lane :release_all do |options|
Fastlane::LaneManager.cruise_lane("android", "release", options)
Fastlane::LaneManager.cruise_lane("ios", "release", options)
end
platform :android do
lane :release do |options|
#do android release
end
end
platform :ios do
lane :release do |options|
#do iOS release
end
end
Upvotes: 5
Reputation: 5174
like this:
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://[email protected]/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'
Now you can run :
yarn app:someapp fastlane setup
or
yarn app:someapp fastlane ios keystore_get stage:'development'
yarn app:someapp fastlane android keystore_get stage:'development'
you can even in CI do :
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
a few extras in here:
Upvotes: 0
Reputation: 190
This isn't the ideal solution as it ends up wrapping your lane execution in another lane but we do this in your equivalent to release_all
, however I wonder if it would allow running those in parallel:
sh "fastlane ios beta"
sh "fastlane android beta"
Upvotes: 5