class Fastlane::Actions::UploadSymbolsToShakeAction
Public Class Methods
available_options()
click to toggle source
# File lib/fastlane/plugin/upload_symbols_to_shake/actions/upload_symbols_to_shake_action.rb, line 103 def self.available_options [ FastlaneCore::ConfigItem.new(key: :client_id, description: "Client id used for auth", type: String, verify_block: proc do |value| unless value && !value.empty? UI.user_error!("No Client id for shake action given, pass using `client_id: 'client id'`") end end), FastlaneCore::ConfigItem.new(key: :client_secret, description: "Client secret used for auth", type: String, verify_block: proc do |value| unless value && !value.empty? UI.user_error!("No Client secret for shake action given, pass using `client_secret: 'client secret'`") end end), FastlaneCore::ConfigItem.new(key: :bundle_id, description: "Bundle id", type: String), FastlaneCore::ConfigItem.new(key: :plist_path, description: "Info.plist path", optional: true, default_value: default_info_plist_path, type: String), FastlaneCore::ConfigItem.new(key: :dsym_array_paths, type: Array, optional: true, description: "Array of paths to *.dSYM files"), FastlaneCore::ConfigItem.new(key: :app_version_name, description: "Application version name", optional: true, default_value: nil, type: String), FastlaneCore::ConfigItem.new(key: :app_version_code, description: "Application version code", optional: true, default_value: nil, type: Integer), FastlaneCore::ConfigItem.new(key: :upload_url, description: "Custom endpoint url", default_value: "https://api.shakebugs.com", optional: true, type: String), ] end
build_single_file_command(command, dsym_path)
click to toggle source
# File lib/fastlane/plugin/upload_symbols_to_shake/actions/upload_symbols_to_shake_action.rb, line 192 def self.build_single_file_command(command, dsym_path) file_path = if dsym_path.end_with?('.zip') dsym_path.shellescape else ZipAction.run(path: dsym_path, include: [], exclude: []).shellescape end command + "@\"#{Shellwords.shellescape(file_path)}\"" end
cleanup_shake_directory()
click to toggle source
# File lib/fastlane/plugin/upload_symbols_to_shake/actions/upload_symbols_to_shake_action.rb, line 168 def self.cleanup_shake_directory FileUtils.rm_f "#{@shake_dsyms_directory}.zip" FileUtils.rm_f @shake_dsyms_directory end
copy_dsmy_paths_into_directory(dsym_paths, directory_path)
click to toggle source
# File lib/fastlane/plugin/upload_symbols_to_shake/actions/upload_symbols_to_shake_action.rb, line 181 def self.copy_dsmy_paths_into_directory(dsym_paths, directory_path) dsym_paths.each do |path| if File.extname(path) == '.dSYM' destination_path = "#{directory_path}/#{File.basename(path)}" FileUtils.copy_entry(path, destination_path) if File.exist?(path) else Actions.sh("unzip -n #{Shellwords.shellescape(path)} -d #{Shellwords.shellescape(directory_path)}") end end end
default_info_plist_path()
click to toggle source
# File lib/fastlane/plugin/upload_symbols_to_shake/actions/upload_symbols_to_shake_action.rb, line 177 def self.default_info_plist_path return Dir.glob("./*/Info.plist").reject{|path| path =~ /build|test|Shake.framework/i }.first end
description()
click to toggle source
# File lib/fastlane/plugin/upload_symbols_to_shake/actions/upload_symbols_to_shake_action.rb, line 85 def self.description "Upload dSYM to Shake" end
details()
click to toggle source
# File lib/fastlane/plugin/upload_symbols_to_shake/actions/upload_symbols_to_shake_action.rb, line 97 def self.details "This action is used to upload symbolication files to Shake. Incase you are not using bitcode, you can use this plug-in with `gym` to upload dSYMs generated from your builds. If bitcode is enabled, you can use it with `download_dsyms` to upload dSYMs from iTunes connect" end
generate_shake_directory()
click to toggle source
# File lib/fastlane/plugin/upload_symbols_to_shake/actions/upload_symbols_to_shake_action.rb, line 163 def self.generate_shake_directory cleanup_shake_directory FileUtils.mkdir_p @shake_dsyms_directory end
is_supported?(platform)
click to toggle source
# File lib/fastlane/plugin/upload_symbols_to_shake/actions/upload_symbols_to_shake_action.rb, line 158 def self.is_supported?(platform) platform == :ios true end
remove_directory(directory_path)
click to toggle source
# File lib/fastlane/plugin/upload_symbols_to_shake/actions/upload_symbols_to_shake_action.rb, line 173 def self.remove_directory(directory_path) FileUtils.rm_rf directory_path end
return_value()
click to toggle source
# File lib/fastlane/plugin/upload_symbols_to_shake/actions/upload_symbols_to_shake_action.rb, line 93 def self.return_value # If your method provides a return value, you can describe here what it does end
run(params)
click to toggle source
# File lib/fastlane/plugin/upload_symbols_to_shake/actions/upload_symbols_to_shake_action.rb, line 9 def self.run(params) @shake_dsyms_directory = 'Shake_dsym_files_fastlane' client_id = params[:client_id] client_secret = params[:client_secret] endpoint_url = params[:upload_url] auth_endpoint = "#{endpoint_url}/auth/oauth2/token" command = "curl --silent -d \"grant_type=client_credentials&client_id=#{client_id}&client_secret=#{client_secret}\" #{auth_endpoint}" result = Actions.sh(command) json_data = JSON.parse(result) if json_data.has_key? 'error' UI.error('Please check your credentials') return 1 end api_token = json_data['access_token'] if params[:app_version_name] == nil && params[:app_version_code] == nil if params[:plist_path] == nil UI.error('Please enter app_version_name and app_version_code or provide path to Info.plist') return 1 end UI.message('Using application version name and code from Info.plist') path = params[:plist_path] UI.verbose "Path to Info.plist: '#{path}'" code = GetInfoPlistValueAction.run(path: path, key: "CFBundleVersion") name = GetInfoPlistValueAction.run(path: path, key: "CFBundleShortVersionString") else name = params[:app_version_name] code = params[:app_version_code] UI.verbose "Using provided app_version_name(#{name}) and app_version_code(#{code})" end bundle_id = params[:bundle_id] upload_file_endpoint = "#{endpoint_url}/api/1.0/crash_reporting/app_debug_file/#{bundle_id}" command = "curl #{upload_file_endpoint} --write-out %{http_code} --silent --output /dev/null -H \"Authorization: Bearer #{api_token}\" -F os=\"iOS\" -F platform=\"iOS\" -F app_version_name=\"#{name}\" -F app_version_code=\"#{code}\" -F file=" dsym_paths = [] #Paths provided by the user dsym_paths += (params[:dsym_array_paths] || []) #Add dSYMs generated by `gym` dsym_paths += [Actions.lane_context[SharedValues::DSYM_OUTPUT_PATH]] if Actions.lane_context[SharedValues::DSYM_OUTPUT_PATH] #Add dSYMs downloaded from iTC dsym_paths += Actions.lane_context[SharedValues::DSYM_PATHS] if Actions.lane_context[SharedValues::DSYM_PATHS] dsym_paths.uniq! UI.verbose 'dsym_paths: ' + dsym_paths.inspect if dsym_paths.empty? UI.error "Fastlane dSYMs file is not found! Make sure you're using Fastlane action [download_dsyms] to download your dSYMs from App Store Connect" return end generate_shake_directory UI.verbose 'Directory name: ' + @shake_dsyms_directory copy_dsmy_paths_into_directory(dsym_paths, @shake_dsyms_directory) command = build_single_file_command(command, @shake_dsyms_directory) result = Actions.sh(command) if result == '200' UI.success 'dSYM is successfully uploaded to Shake' UI.verbose 'Removing The directory' else UI.error "Something went wrong during Shake dSYM upload. Status cose is #{result}" end cleanup_shake_directory remove_directory(@shake_dsyms_directory) end