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 "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 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 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, tag_name: GITHUB_RELEASE, 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" private_lane :build_ios do BUILD_DIRECTORY = "./ios/build" update_versions prepare_appstore setup_ci case ENVIRONMENT when "development" match( type: "development", readonly: true ) match_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" 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