tooot/fastlane/Fastfile

142 lines
4.0 KiB
Ruby

fastlane_version "2.172.0"
skip_docs
ensure_env_vars(
env_vars: ["TOOOT_ENVIRONMENT"]
)
VERSIONS = read_json( json_path: "./package.json" )[:versions]
ENVIRONMENT = ENV["TOOOT_ENVIRONMENT"]
VERSION = "#{VERSIONS[:major]}.#{VERSIONS[:minor]}"
RELEASE_CHANNEL = "#{VERSIONS[:major]}-#{ENVIRONMENT}"
BUILD_NUMBER = ENV["GITHUB_RUN_NUMBER"]
GITHUB_REPO = "tooot-app/app"
case ENVIRONMENT
when "development"
GITHUB_RELEASE= ""
when "staging"
GITHUB_RELEASE = "v#{VERSION} (#{BUILD_NUMBER})"
when "production"
GITHUB_RELEASE = "v#{VERSION}"
end
XCODEPROJ = "./ios/tooot.xcodeproj"
INFO_PLIST = "./ios/tooot/Info.plist"
EXPO_PLIST = "./ios/tooot/Supporting/Expo.plist"
desc "IOS: Prepare app store"
private_lane :prepare_appstore_ios do
case ENVIRONMENT
when "staging", "production"
increment_build_number( xcodeproj: XCODEPROJ, build_number: BUILD_NUMBER )
app_store_connect_api_key
end
end
desc 'IOS: Update version information'
private_lane :update_versions_ios do
set_info_plist_value( path: INFO_PLIST, key: "CFBundleShortVersionString", value: VERSION )
set_info_plist_value( path: EXPO_PLIST, key: "EXUpdatesSDKVersion", value: VERSIONS[:expo] )
set_info_plist_value( path: EXPO_PLIST, key: "EXUpdatesReleaseChannel", value: RELEASE_CHANNEL )
end
desc "Create new GitHub release"
private_lane :github_release do
case ENVIRONMENT
when "staging"
is_prerelease = true
when "production"
is_prerelease = false
end
set_github_release(
repository_name: GITHUB_REPO,
name: GITHUB_RELEASE,
tag_name: GITHUB_RELEASE,
description: "No changelog provided",
commitish: git_branch,
is_prerelease: is_prerelease
)
end
desc "Expo release"
private_lane :expo_release do
yarn( package_path: "./package.json", flags: "release", command: RELEASE_CHANNEL )
end
desc "Build and deploy iOS app"
private_lane :build_ios do
BUILD_DIRECTORY = "./ios/build"
update_versions_ios
prepare_appstore_ios
setup_ci
case ENVIRONMENT
when "development"
match( type: "development", readonly: true )
build_ios_app( export_method: "development", output_directory: BUILD_DIRECTORY, output_name: "#{VERSION}-#{BUILD_NUMBER}" )
install_on_device( skip_wifi: true )
when "staging"
match( type: "appstore", readonly: true )
build_ios_app( export_method: "app-store" )
upload_to_testflight(
demo_account_required: true,
distribute_external: true,
groups: "内测用户",
changelog: "Ready for testing"
)
when "production"
match( type: "appstore", readonly: true )
build_ios_app( export_method: "app-store" )
end
end
desc "Build and deploy Android app"
private_lane :build_android do
case ENVIRONMENT
when "development"
build_android_app(
task: 'assemble',
build_type: 'Debug',
project_dir: "./android",
properties: {
"android.injected.signing.store.file" => "keystore.jks",
"android.injected.signing.store.password" => "store_password",
"android.injected.signing.key.alias" => "key_alias",
"android.injected.signing.key.password" => "key_password",
}
)
puts lane_context[SharedValues::GRADLE_APK_OUTPUT_PATH]
when "staging"
match( type: "appstore", readonly: true )
build_ios_app( export_method: "app-store" )
upload_to_testflight(
demo_account_required: true,
distribute_external: true,
groups: "内测用户",
changelog: "Ready for testing"
)
when "production"
match( type: "appstore", readonly: true )
build_ios_app( export_method: "app-store" )
end
end
lane :build do
releaseExists = get_github_release(url: GITHUB_REPO, version: GITHUB_RELEASE)
if releaseExists
puts("Release #{GITHUB_RELEASE} exists. Continue with building React Native only.")
else
puts("Release #{GITHUB_RELEASE} does not exist. Create new release as well as new native build.")
build_ios
# build_android
case ENVIRONMENT
when "staging"
github_release
when "production"
github_release
end
end
# expo_release
rocket
end