Class: Fastlane::Actions::AnnaiUploadToPlayStoreAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::AnnaiUploadToPlayStoreAction
- Defined in:
- lib/fastlane/plugin/ann_flutter_flavor/actions/ann_upload_to_play_store_action.rb
Overview
This class name dictates the action name ‘ann_upload_to_play_store’
Class Method Summary collapse
-
.available_options ⇒ Object
—————————————————- Define Parameters —————————————————-.
- .description ⇒ Object
- .example_code ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .run(params) ⇒ Object
Class Method Details
.available_options ⇒ Object
Define Parameters
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
# File 'lib/fastlane/plugin/ann_flutter_flavor/actions/ann_upload_to_play_store_action.rb', line 146 def self. [ FastlaneCore::ConfigItem.new(key: :flavor, description: "The specific flavor(s) to upload (comma-separated). If nil, all flavors are uploaded", optional: true, default_value: nil), FastlaneCore::ConfigItem.new(key: :spec_file, description: "Path to the annai spec configuration file (relative to flutter root). Defaults to standard discovery", optional: true, default_value: nil), FastlaneCore::ConfigItem.new(key: :clean, description: "If true, runs annai_clean_build before uploading (and compiling if not skipped)", type: Boolean, default_value: false), # --- Common & Android Specific Parameters --- FastlaneCore::ConfigItem.new(key: :api_key_path, description: "Path to the Google Service Account JSON file", optional: true, type: String), FastlaneCore::ConfigItem.new(key: :main_file, description: "Path to the main dart file (used if compilation is required)", default_value: "lib/main.dart"), FastlaneCore::ConfigItem.new(key: :skip_compile, description: "If true, skips the compilation step and assumes artifacts already exist", type: Boolean, default_value: false), FastlaneCore::ConfigItem.new(key: :skip_sound_null_safety, description: "Skips sound null safety checks during compilation (if skip_compile is false)", type: Boolean, default_value: false), FastlaneCore::ConfigItem.new(key: :skip_upload_prod, description: "If true, skips uploading to the production track", type: Boolean, default_value: false), FastlaneCore::ConfigItem.new(key: :skip_upload_binary, description: "If true, skips uploading the binary (.aab)", type: Boolean, default_value: false), FastlaneCore::ConfigItem.new(key: :skip_upload_metadata, description: "If true, skips uploading store metadata (description, title, etc)", type: Boolean, default_value: false), FastlaneCore::ConfigItem.new(key: :skip_upload_screenshots, description: "If true, skips uploading screenshots and app previews", type: Boolean, default_value: false), FastlaneCore::ConfigItem.new(key: :metadata_path, description: "The path to the localized store metadata (e.g., fastlane/metadata/android)", optional: true, default_value: nil), FastlaneCore::ConfigItem.new(key: :package_name, description: "The package name (Android)", optional: true, default_value: nil), FastlaneCore::ConfigItem.new(key: :track, description: "The track to upload to (e.g., internal, alpha, beta, production)", optional: true, default_value: "beta"), FastlaneCore::ConfigItem.new(key: :track_promote_to, description: "The track to promote to after upload", optional: true, default_value: "production"), FastlaneCore::ConfigItem.new(key: :priority, description: "In-app update priority (0-5)", optional: true, type: Integer, default_value: 1), FastlaneCore::ConfigItem.new(key: :skip_upload_changelogs, description: "If true, skips uploading changelogs", type: Boolean, default_value: false), FastlaneCore::ConfigItem.new(key: :skip_upload_images, description: "If true, skips uploading promotional images", type: Boolean, default_value: false), ].compact end |
.description ⇒ Object
228 229 230 |
# File 'lib/fastlane/plugin/ann_flutter_flavor/actions/ann_upload_to_play_store_action.rb', line 228 def self.description "Handles compilation (optional) and uploading of one or all flavors to the Google Play Store" end |
.example_code ⇒ Object
236 237 238 239 240 241 242 243 244 245 |
# File 'lib/fastlane/plugin/ann_flutter_flavor/actions/ann_upload_to_play_store_action.rb', line 236 def self.example_code 'ann_upload_to_play_store( flavor: "production", spec_file: "config/annai_config.yaml", # Optional custom spec path package_name: "com.example.app", api_key_path: "./api_keys/google.json", track: "production", skip_compile: false )' end |
.is_supported?(platform) ⇒ Boolean
232 233 234 |
# File 'lib/fastlane/plugin/ann_flutter_flavor/actions/ann_upload_to_play_store_action.rb', line 232 def self.is_supported?(platform) platform == :android end |
.run(params) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/fastlane/plugin/ann_flutter_flavor/actions/ann_upload_to_play_store_action.rb', line 10 def self.run(params) platform = :android # Hardcoded platform action_name = "ann_upload_to_play_store" requested_flavor = params[:flavor] requested_clean_build = params[:clean] spec_file = params[:spec_file] # 1. Initialize AnnaiLanes annai_lanes = FastlaneFlutterFlavor::AnnaiLanes.new( lane: self, platform: platform, # Pass platform symbol directly spec_file: spec_file # Pass optional spec_file ) status_manager = annai_lanes.instance_variable_get(:@statusManager) spec_loader = annai_lanes.instance_variable_get(:@specLoader) UI.user_error!("Internal Error: AnnaiLanes failed to initialize specLoader") unless spec_loader any_upload_failed = false # 2. Perform clean build if requested if requested_clean_build UI.header("🧹 Cleaning builds as requested...") begin annai_lanes.clean_build rescue => e UI.error("Failed to perform clean build: #{e.}. Attempting to proceed with upload") # Note: Using 'annai_clean_build' as the action name for the failure log status_manager.logError("All", "annai_clean_build", platform, "Clean build failed: #{e.}") end end # 3. Get the list of all flavors defined for the platform flavors_hash = spec_loader.get_platform_flavors(platform) if flavors_hash.empty? UI.important("No flavors found for Android in the Annai spec. Nothing to upload") annai_lanes.finalize return end all_flavor_names = flavors_hash.keys # 4. Determine which flavors to upload if requested_flavor && !requested_flavor.to_s.empty? requested_flavors = requested_flavor.to_s.split(',').map(&:strip).reject(&:empty?) # Validate all requested flavors invalid_flavors = requested_flavors.reject { |f| all_flavor_names.include?(f) } if invalid_flavors.any? UI.user_error!("The following requested flavor(s) are not found in the Annai spec for Android: #{invalid_flavors.join(', ')}. Available flavors: #{all_flavor_names.join(', ')}") end flavors_to_upload = requested_flavors else flavors_to_upload = all_flavor_names end UI.header("Starting Google Play upload. Flavors to process: #{flavors_to_upload.join(', ')}") # 5. Loop through each flavor and upload flavors_to_upload.each do |flavor_key| flavor = flavor_key.to_s # Get values, prioritizing spec over parameters final_main_file = spec_loader.get_main_file(platform, flavor) || params[:main_file] final_api_key_path = spec_loader.get_api_key_path(platform, flavor) || params[:api_key_path] final_priority = spec_loader.get_priority(platform, flavor) || params[:priority] final_package_name = spec_loader.get_package_id(platform, flavor) || params[:package_name] UI.("🚀 Preparing **#{flavor}** flavor...") # Use 'upload_to_store' as the consistent action name for flavor-specific failures flavor_action_name = "upload_to_store" begin # Android Upload Logic (upload_to_play_store) success = annai_lanes.upload_to_play_store( package_name: final_package_name, api_key_path: final_api_key_path, in_app_update_priority: final_priority, flavor: flavor, main_file: final_main_file, track: params[:track], track_promote_to: params[:track_promote_to], skip_sound_null_safety: params[:skip_sound_null_safety], skip_compile: params[:skip_compile], skip_upload_prod: params[:skip_upload_prod], skip_upload_binary: params[:skip_upload_binary], skip_upload_changelogs: params[:skip_upload_changelogs], skip_upload_metadata: params[:skip_upload_metadata], skip_upload_images: params[:skip_upload_images], skip_upload_screenshots: params[:skip_upload_screenshots], platform: platform.to_s, metadata_path: params[:metadata_path], ) if success UI.success("✅ Successfully uploaded flavor: #{flavor}") else # If upload_to_play_store returns false (meaning it caught an error and logged it), flag the overall failure. if !status_manager.instance_variable_get(:@status).key?([flavor, flavor_action_name, platform.to_s]) raise "Upload failed for flavor '#{flavor}'" else raise "Upload failed for flavor '#{flavor}' (error logged previously)" end end rescue => e # Failure handling: Log the error and continue if !status_manager.instance_variable_get(:@status).key?([flavor, flavor_action_name, platform.to_s]) status_manager.logError(flavor, flavor_action_name, platform, e.) end UI.error("❌ Failed to upload flavor: #{flavor}. Continuing to next flavor...") any_upload_failed = true # Continue to the next flavor end end # 6. Final Reporting and Status Check annai_lanes.finalize if any_upload_failed UI.user_error!("Upload failed for one or more flavors. See the Annai Fastlane summary above") else UI.success("🎉 Successfully uploaded all #{flavors_to_upload.count} requested flavor(s) to the Google Play Store!") end end |