Class: Fastlane::Actions::CiSetupAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::CiSetupAction
- Defined in:
- lib/fastlane/plugin/yalantis_ci/actions/ci_setup.rb
Documentation collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .output ⇒ Object
Class Method Summary collapse
- .run(params) ⇒ Object
- .setup_match_repo(branch_name) ⇒ Object
- .setup_temp_keychain(id) ⇒ Object
- .unique_id(project) ⇒ Object
Class Method Details
.authors ⇒ Object
159 160 161 |
# File 'lib/fastlane/plugin/yalantis_ci/actions/ci_setup.rb', line 159 def self. ["Dima Vorona", "Yalantis"] end |
.available_options ⇒ Object
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 151 |
# File 'lib/fastlane/plugin/yalantis_ci/actions/ci_setup.rb', line 120 def self. # Define all options your action supports. # Below a few examples [ FastlaneCore::ConfigItem.new(key: :derived_data_path, env_name: "CI_DERIVED_DATA_PATH", description: "Path to the derived data to be used", is_string: true, default_value: "./build/DerivedData" ), FastlaneCore::ConfigItem.new(key: :output_directory, env_name: "CI_OUTPUT_DIRECTORY", description: "The directory in which the ipa file should be stored in as well as .xcarchive", is_string: true, default_value: "./build" ), FastlaneCore::ConfigItem.new(key: :archive_name, env_name: "CI_ARCHIVE_NAME", description: "The name of the .xcarchive to be used. Valid only when :output_directory is passed", is_string: true, optional: true ), FastlaneCore::ConfigItem.new(key: :project, env_name: "XC_PROJECT", description: "Path to the .xcodeproj to be used or any project-related description. Used during CI_UNIQUE_PROJECT_ID generation", is_string: true, optional: false ), ] end |
.description ⇒ Object
110 111 112 |
# File 'lib/fastlane/plugin/yalantis_ci/actions/ci_setup.rb', line 110 def self.description "Setup Yalantis-specific settings for CI" end |
.details ⇒ Object
114 115 116 117 118 |
# File 'lib/fastlane/plugin/yalantis_ci/actions/ci_setup.rb', line 114 def self.details # Optional: # this is your chance to provide a more detailed description of this action "CI Setup action setups CI-specific variables such as build path, derived data path, etc" end |
.is_supported?(platform) ⇒ Boolean
163 164 165 |
# File 'lib/fastlane/plugin/yalantis_ci/actions/ci_setup.rb', line 163 def self.is_supported?(platform) [:ios, :mac].include?(platform) end |
.output ⇒ Object
153 154 155 156 157 |
# File 'lib/fastlane/plugin/yalantis_ci/actions/ci_setup.rb', line 153 def self.output [ ['CI_UNIQUE_PROJECT_ID', 'A unique project id being used for the match branch name, keychain name, etc'] ] end |
.run(params) ⇒ Object
8 9 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 |
# File 'lib/fastlane/plugin/yalantis_ci/actions/ci_setup.rb', line 8 def self.run(params) # Print table FastlaneCore::PrintTable.print_values( config: params, title: "Summary for CI Setup Action" ) id = self.unique_id(params[:project]) UI.("Setting CI_UNIQUE_PROJECT_ID to: \"#{id}\"") Actions.lane_context[SharedValues::CI_UNIQUE_PROJECT_ID] = id ENV['CI_UNIQUE_PROJECT_ID'] = id # We want to setup match repo regardless of the environment. # On both local and remote machine this should be set to the same value self.setup_match_repo(id) if !Helper.ci? return end self.setup_temp_keychain(id) # Set output directory if params[:output_directory] output_directory_path = File.(params[:output_directory]) UI.("Setting output directory path to: \"#{output_directory_path}\".") ENV['GYM_BUILD_PATH'] = output_directory_path ENV['GYM_OUTPUT_DIRECTORY'] = output_directory_path ENV['SCAN_OUTPUT_DIRECTORY'] = output_directory_path ENV['BACKUP_XCARCHIVE_DESTINATION'] = output_directory_path if params[:archive_name] extension = "xcarchive" archive_name = File.basename(params[:archive_name], File.extname(params[:archive_name])) + extension archive_path = File.join(output_directory_path, params[:archive_name]) UI.("Setting archive path to: \"#{output_directory_path}\".") ENV['GYM_ARCHIVE_PATH'] = archive_path end end # Set derived data if params[:derived_data_path] derived_data_path = File.(params[:derived_data_path]) UI.("Setting derived data path to: \"#{derived_data_path}\".") ENV['DERIVED_DATA_PATH'] = derived_data_path # Used by clear_derived_data. ENV['XCODE_DERIVED_DATA_PATH'] = derived_data_path ENV['GYM_DERIVED_DATA_PATH'] = derived_data_path ENV['SCAN_DERIVED_DATA_PATH'] = derived_data_path ENV['FL_CARTHAGE_DERIVED_DATA'] = derived_data_path ENV['FL_SLATHER_BUILD_DIRECTORY'] = derived_data_path end end |
.setup_match_repo(branch_name) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/fastlane/plugin/yalantis_ci/actions/ci_setup.rb', line 70 def self.setup_match_repo(branch_name) # We need to setup a unique name for Match Repo to not interfere with any other # project. Project name includes normalized xcodeproj name and team id. # This ensures that same project can use different teams simultaniously. if ENV['MATCH_GIT_BRANCH'].nil? UI.("Setting Match repo branch to: \"#{branch_name}\"") ENV['MATCH_GIT_BRANCH'] = branch_name else UI.("Skipping Match being set to: \"#{ENV['MATCH_GIT_BRANCH']}\"") end end |
.setup_temp_keychain(id) ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/fastlane/plugin/yalantis_ci/actions/ci_setup.rb', line 82 def self.setup_temp_keychain(id) job_id = ENV['CI_JOBENV_ID'] || '' name = "#{id}-#{job_id}-fastlane" password = "#{name}-password" path = File.("~/Library/Keychains/#{name}.keychain-db") ENV['KEYCHAIN_PASSWORD'] = password ENV['KEYCHAIN_PATH'] = path ENV['MATCH_KEYCHAIN_NAME'] = name ENV['MATCH_KEYCHAIN_PASSWORD'] = password # In case job has been cancelled, Fastlane's hooks don't get invoked. # It may lead to a keychain creation failures. Therefore we need to wipe-out # previous keychain (if exists). if File.exist?(ENV['KEYCHAIN_PATH']) UI.("Removing dangling temporary keychain at: \"#{ENV['KEYCHAIN_PATH']}\"") other_action.delete_keychain end UI.("Setting temporary keychain path to: \"#{path}\"") other_action.create_keychain(unlock: true, timeout: 0, add_to_search_list: true) end |
.unique_id(project) ⇒ Object
62 63 64 65 66 67 68 |
# File 'lib/fastlane/plugin/yalantis_ci/actions/ci_setup.rb', line 62 def self.unique_id(project) # Ensure that MATCH_GIT_BRANCH is set to a unique name to not commit to the master. normalized_xcodeproj = File.basename(project, File.extname(project)).gsub(/[^0-9a-z]/i, '-').downcase team_id = CredentialsManager::AppfileConfig.try_fetch_value(:team_id) || ENV['FASTLANE_TEAM_ID'] team_id.empty? ? normalized_xcodeproj : "#{normalized_xcodeproj}-#{team_id}" end |