# This file contains the fastlane.tools configuration # You can find the documentation at https://docs.fastlane.tools # # For a list of all available actions, check out # # https://docs.fastlane.tools/actions # # For a list of all available plugins, check out # # https://docs.fastlane.tools/plugins/available-plugins # # Uncomment the line if you want fastlane to automatically update itself # update_fastlane default_platform(:android) platform :android do before_all do FIREBASE_DISTRIBUTION_INTERNAL_APP = "1:64659984801:android:7a0514333a32b8c5f43be0" FIREBASE_APP_DISTRIBUTION_GROUPS_QA = "android-qa" INTERNAL_APP_IDENTIFIER = "com.initproject.staging" PROD_APP_IDENTIFIER = "com.initproject.prod" # Environment variable should be the full path to the firebase auth .json FIREBASE_DISTRIBUTION_AUTH_FILE = ENV['CI_EVAL_FIREBASE_DISTRIBUTION_AUTH_FILE'] # Environment variable should be the full path to the PlayStore auth .json PLAY_STORE_AUTH_FILE = ENV['CI_EVAL_ANDROID_PLAY_STORE_AUTH_FILE'] end desc "Submit a new Internal Build to Firebase" desc ">Optionally release notes can be added like so:" desc "```sh" desc "[bundle exec] fastlane deployInternalToFirebase release_notes:\"testing notes\"" desc "```" lane :deployInternalToFirebase do |options| release_notes = options[:release_notes] if release_notes.nil? || release_notes.empty? commit = last_git_commit release_notes = "Last commit with hash: #{commit[:commit_hash]} and message: #{commit[:message]}" end buildReleaseApk() internal_apk = lane_context[SharedValues::GRADLE_ALL_APK_OUTPUT_PATHS].find{ |i| i[/app-*release*.apk/] } firebase_app_distribution( service_credentials_file: FIREBASE_DISTRIBUTION_AUTH_FILE, app: FIREBASE_DISTRIBUTION_INTERNAL_APP, groups: FIREBASE_APP_DISTRIBUTION_GROUPS_QA, android_artifact_type: 'APK', android_artifact_path: internal_apk, release_notes: "#{release_notes}", ) end desc "Create new Release APK" desc "Find it under app/build/outputs/apk/release" lane :buildReleaseApk do gradle(task: 'clean', flags: "--no-daemon") gradle( task: 'assemble', build_type: 'release', flags: "--no-daemon", properties: { "applicationId" => INTERNAL_APP_IDENTIFIER, "useDebugSigningForReleaseBuild" => "true" } ) end desc "Submit a new Production Build to Play Store" desc "By Default it sets the version_code to last from PlayStore + 1." desc ">Optionally version code increase can be skipped via:" desc "```sh" desc "[bundle exec] fastlane deployProdToPlayStore skip_build_number_increase:true" desc "```" lane :deployProdToPlayStore do |options| skip_build_number_increase = options[:skip_build_number_increase] # optional, if not set, it gets the last from PlayStore then adds + 1 package_name = PROD_APP_IDENTIFIER if skip_build_number_increase.nil? || !skip_build_number_increase last_version_codes = google_play_track_version_codes( track: 'internal', json_key: PLAY_STORE_AUTH_FILE, package_name: package_name ) last_version_code = last_version_codes[0] version_code = last_version_code + 1 end gradle(task: 'clean', flags: "--no-daemon") gradle( task: 'bundle', build_type: 'release', flags: "--no-daemon", properties: { "applicationId" => PROD_APP_IDENTIFIER, "versionCode" => version_code } ) production_aab = lane_context[SharedValues::GRADLE_ALL_AAB_OUTPUT_PATHS].find{ |i| i[/app-*release*.aab/] } upload_to_play_store( track: 'internal', release_status: 'draft', # can remove once app is released to the public aab: production_aab, json_key: PLAY_STORE_AUTH_FILE, skip_upload_apk: true, package_name: package_name, ) end end