2021-02-02 22:50:38 +01:00
|
|
|
fastlane_version "2.172.0"
|
2021-01-31 03:09:35 +01:00
|
|
|
|
2021-02-02 22:50:38 +01:00
|
|
|
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 = Time.now.strftime("%y%m%d")
|
2021-01-31 03:09:35 +01:00
|
|
|
|
|
|
|
platform :ios do
|
2021-02-02 22:50:38 +01:00
|
|
|
XCODEPROJ = "./ios/tooot.xcodeproj"
|
|
|
|
INFO_PLIST = "./ios/tooot/Info.plist"
|
|
|
|
EXPO_PLIST = "./ios/tooot/Supporting/Expo.plist"
|
2021-01-31 03:09:35 +01:00
|
|
|
|
2021-02-02 22:50:38 +01:00
|
|
|
desc "Prepare app store"
|
|
|
|
private_lane :prepare_appstore do
|
|
|
|
case ENVIRONMENT
|
|
|
|
when "staging", "production"
|
|
|
|
increment_build_number( xcodeproj: XCODEPROJ, build_number: BUILD_NUMBER )
|
|
|
|
app_store_connect_api_key
|
2021-01-31 03:09:35 +01:00
|
|
|
end
|
2021-02-02 22:50:38 +01:00
|
|
|
end
|
2021-01-31 03:09:35 +01:00
|
|
|
|
2021-02-02 22:50:38 +01:00
|
|
|
desc "Expo release"
|
|
|
|
private_lane :expo_release do
|
|
|
|
yarn( package_path: "./package.json", flags: "release", command: RELEASE_CHANNEL )
|
|
|
|
end
|
2021-01-31 03:09:35 +01:00
|
|
|
|
2021-02-02 22:50:38 +01:00
|
|
|
desc "Get certificates"
|
|
|
|
private_lane :get_certificates do |options|
|
|
|
|
if ENV['CI'] == true
|
|
|
|
match( type: options[:type], readonly: true, keychain_name: KEYCHAIN_NAME, keychain_password: KEYCHAIN_PASS )
|
|
|
|
else
|
|
|
|
match( type: options[:type], readonly: true )
|
2021-01-31 03:09:35 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-02-02 22:50:38 +01:00
|
|
|
desc "Build and deploy"
|
|
|
|
lane :build do
|
|
|
|
BUILD_DIRECTORY = "./ios/build"
|
|
|
|
SHOULD_BUILD_NATIVE = false
|
2021-01-31 03:09:35 +01:00
|
|
|
|
2021-02-02 22:50:38 +01:00
|
|
|
case ENVIRONMENT
|
|
|
|
when "staging", "production"
|
|
|
|
PREVIOUS_VERSION = get_info_plist_value( path: INFO_PLIST, key: "CFBundleShortVersionString" )
|
|
|
|
if VERSION.to_f > PREVIOUS_VERSION.to_f
|
|
|
|
SHOULD_BUILD_NATIVE = true
|
|
|
|
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
|
|
|
|
when "development"
|
|
|
|
SHOULD_BUILD_NATIVE = true
|
|
|
|
end
|
|
|
|
|
|
|
|
if SHOULD_BUILD_NATIVE == true
|
|
|
|
prepare_appstore
|
|
|
|
|
2021-02-03 16:45:43 +01:00
|
|
|
setup_ci
|
2021-02-02 22:50:38 +01:00
|
|
|
|
|
|
|
case ENVIRONMENT
|
|
|
|
when "development"
|
|
|
|
get_certificates( type: "development" )
|
|
|
|
build_ios_app(
|
|
|
|
export_method: "development",
|
|
|
|
output_directory: BUILD_DIRECTORY,
|
|
|
|
output_name: VERSION + "-" + BUILD_NUMBER
|
|
|
|
)
|
|
|
|
install_on_device( skip_wifi: true )
|
|
|
|
when "staging"
|
|
|
|
get_certificates( type: "appstore" )
|
|
|
|
build_ios_app(
|
|
|
|
export_method: "app-store",
|
|
|
|
output_directory: BUILD_DIRECTORY,
|
|
|
|
output_name: VERSION + "-" + BUILD_NUMBER
|
|
|
|
)
|
|
|
|
upload_to_testflight(
|
|
|
|
demo_account_required: true,
|
|
|
|
distribute_external: true,
|
|
|
|
groups: "内测用户",
|
|
|
|
changelog: "Ready for testing"
|
|
|
|
)
|
|
|
|
when "production"
|
|
|
|
get_certificates( type: "appstore" )
|
|
|
|
build_ios_app(
|
|
|
|
export_method: "app-store",
|
|
|
|
output_directory: BUILD_DIRECTORY,
|
|
|
|
output_name: VERSION + "-" + BUILD_NUMBER
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
2021-01-31 03:09:35 +01:00
|
|
|
|
2021-02-02 22:50:38 +01:00
|
|
|
expo_release
|
2021-01-31 03:09:35 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
platform :android do
|
2021-02-02 23:29:36 +01:00
|
|
|
|
2021-01-31 03:09:35 +01:00
|
|
|
end
|