fastlane_version "2.172.0" 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") platform :ios do XCODEPROJ = "./ios/tooot.xcodeproj" INFO_PLIST = "./ios/tooot/Info.plist" EXPO_PLIST = "./ios/tooot/Supporting/Expo.plist" 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 end end desc "Expo release" private_lane :expo_release do yarn( package_path: "./package.json", flags: "release", command: RELEASE_CHANNEL ) end desc "Get certificates" private_lane :get_certificates do |options| if ENV['CI'] == true match( type: options[:type], readonly: true ) else match( type: options[:type], readonly: true ) end end desc "Build and deploy" lane :build do BUILD_DIRECTORY = "./ios/build" SHOULD_BUILD_NATIVE = false 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 setup_ci 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 expo_release end end platform :android do end