Class: Fastlane::Actions::AnnaiUploadToAppStoreAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::AnnaiUploadToAppStoreAction
- Defined in:
- lib/fastlane/plugin/ann_flutter_flavor/actions/ann_upload_to_app_store_action.rb
Overview
This class name dictates the action name ‘ann_upload_to_app_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
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 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 |
# File 'lib/fastlane/plugin/ann_flutter_flavor/actions/ann_upload_to_app_store_action.rb', line 155 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), FastlaneCore::ConfigItem.new(key: :distribution_platform, description: "The distribution platform (e.g., 'ios' or 'app_store_connect') for App Store uploads", optional: true, default_value: "ios"), # --- Common & iOS Specific Parameters --- FastlaneCore::ConfigItem.new(key: :api_key_path, description: "Path to the App Store Connect API Key JSON file (iOS)", 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/stage", type: Boolean, default_value: false), FastlaneCore::ConfigItem.new(key: :skip_upload_binary, description: "If true, skips uploading the binary (.ipa)", 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/ios)", optional: true, default_value: nil), FastlaneCore::ConfigItem.new(key: :screenshots_path, description: "The path to the screenshots and app previews", optional: true, default_value: nil), FastlaneCore::ConfigItem.new(key: :bundle_identifier, description: "The bundle identifier (iOS)", optional: true, default_value: nil), FastlaneCore::ConfigItem.new(key: :display_name, description: "The display name of the app (used for IPA filename)", optional: true, default_value: "App"), FastlaneCore::ConfigItem.new(key: :export_option_file, description: "Path to export options plist", optional: true, default_value: ""), FastlaneCore::ConfigItem.new(key: :team_id, description: "Apple Developer Team ID", optional: true, default_value: nil), FastlaneCore::ConfigItem.new(key: :signing_certificate, description: "Code signing certificate name", optional: true, default_value: "iPhone Distribution"), FastlaneCore::ConfigItem.new(key: :app_version, description: "The app version number", optional: true, default_value: nil), FastlaneCore::ConfigItem.new(key: :build_number, description: "The build number", optional: true, default_value: nil), FastlaneCore::ConfigItem.new(key: :export_compliance_uses_encryption, description: "Whether the app uses encryption", optional: true, type: Boolean, default_value: nil), FastlaneCore::ConfigItem.new(key: :add_id_info_uses_idfa, description: "Whether the app uses IDFA", optional: true, type: Boolean, default_value: nil), ].compact end |
.description ⇒ Object
259 260 261 |
# File 'lib/fastlane/plugin/ann_flutter_flavor/actions/ann_upload_to_app_store_action.rb', line 259 def self.description "Handles compilation (optional) and uploading of one or all flavors to the Apple App Store" end |
.example_code ⇒ Object
267 268 269 270 271 272 273 274 275 276 277 |
# File 'lib/fastlane/plugin/ann_flutter_flavor/actions/ann_upload_to_app_store_action.rb', line 267 def self.example_code 'ann_upload_to_app_store( flavor: "production", spec_file: "config/annai_config.yaml", # Optional custom spec path api_key_path: "./api_keys/asc.json", bundle_identifier: "com.example.app", team_id: "ABCDEFG", clean: true, skip_compile: false )' end |
.is_supported?(platform) ⇒ Boolean
263 264 265 |
# File 'lib/fastlane/plugin/ann_flutter_flavor/actions/ann_upload_to_app_store_action.rb', line 263 def self.is_supported?(platform) platform == :ios 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 142 143 144 145 146 147 148 149 150 |
# File 'lib/fastlane/plugin/ann_flutter_flavor/actions/ann_upload_to_app_store_action.rb', line 10 def self.run(params) platform = :ios # Hardcoded platform action_name = "ann_upload_to_app_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 iOS 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 IOS: #{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 App Store 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_package_name = spec_loader.get_package_id(platform, flavor) || params[:bundle_identifier] final_export_option_file = spec_loader.get_export_option_file(platform, flavor) || params[:export_option_file] final_display_name = spec_loader.get_display_name(platform, flavor) || params[:display_name] final_team_id = spec_loader.get_team_id(platform, flavor) || params[:team_id] final_app_version = spec_loader.get_version_name(platform, flavor) || params[:app_version] final_build_number = spec_loader.get_version_code(platform, flavor) || params[:build_number] UI.("🚀 Preparing **#{flavor}** flavor...") # Use 'upload_to_store' as the consistent action name for flavor-specific failures flavor_action_name = "upload_to_store" begin # iOS Upload Logic (upload_to_app_store) success = annai_lanes.upload_to_app_store( bundle_identifier: final_package_name, # Use package name from spec for bundle ID api_key_path: final_api_key_path, flavor: flavor, main_file: final_main_file, display_name: final_display_name, export_option_file: final_export_option_file, team_id: final_team_id, signing_certificate: params[:signing_certificate], app_version: final_app_version, build_number: final_build_number, skip_sound_null_safety: params[:skip_sound_null_safety], skip_compile: params[:skip_compile], skip_upload_binary: params[:skip_upload_binary], skip_upload_prod: params[:skip_upload_prod], skip_upload_metadata: params[:skip_upload_metadata], skip_upload_screenshots: params[:skip_upload_screenshots], export_compliance_uses_encryption: params[:export_compliance_uses_encryption], add_id_info_uses_idfa: params[:add_id_info_uses_idfa], platform: platform.to_s, metadata_path: params[:metadata_path], screenshots_path: params[:screenshots_path], distribution_platform: params[:distribution_platform], ) if success UI.success("✅ Successfully uploaded flavor: #{flavor}") else # If upload_to_app_store returns false (meaning it caught an error and logged it), flag the overall failure. # We only raise/log here if the inner action didn't handle it, to ensure logging consistency. 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 App Store!") end end |