Class: Fastlane::Actions::CleanBuildArtifactsAction

Inherits:
Fastlane::Action show all
Defined in:
lib/fastlane/actions/clean_build_artifacts.rb

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, authors, details, method_missing, other_action, output, return_value, sh, step_text

Class Method Details

.authorObject



41
42
43
# File 'lib/fastlane/actions/clean_build_artifacts.rb', line 41

def self.author
  "lmirosevic"
end

.available_optionsObject



27
28
29
30
31
32
33
34
35
# File 'lib/fastlane/actions/clean_build_artifacts.rb', line 27

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :exclude_pattern,
                                 env_name: "FL_CLEAN_BUILD_ARTIFACTS_EXCLUDE_PATTERN",
                                 description: "Exclude all files from clearing that match the given Regex pattern: e.g. '.*\.mobileprovision'",
                                 default_value: nil,
                                 optional: true)
  ]
end

.descriptionObject



37
38
39
# File 'lib/fastlane/actions/clean_build_artifacts.rb', line 37

def self.description
  "Deletes files created as result of running ipa, cert, sigh or download_dsyms"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/fastlane/actions/clean_build_artifacts.rb', line 45

def self.is_supported?(platform)
  [:ios, :mac].include? platform
end

.run(options) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fastlane/actions/clean_build_artifacts.rb', line 4

def self.run(options)
  paths = [
    Actions.lane_context[Actions::SharedValues::IPA_OUTPUT_PATH],
    Actions.lane_context[Actions::SharedValues::DSYM_OUTPUT_PATH],
    Actions.lane_context[Actions::SharedValues::CERT_FILE_PATH]
  ]

  paths += Actions.lane_context[Actions::SharedValues::SIGH_PROFILE_PATHS] || []
  paths += Actions.lane_context[Actions::SharedValues::DSYM_PATHS] || []
  paths = paths.uniq

  paths.reject { |file| file.nil? || !File.exist?(file) }.each do |file|
    if options[:exclude_pattern]
      next if file.match(options[:exclude_pattern])
    end

    UI.verbose("Cleaning up '#{file}'")
    File.delete(file)
  end

  UI.success('Cleaned up build artifacts 🐙')
end