Class: Fastlane::Actions::CleanBuildArtifactsAction

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

Constant Summary

Constants inherited from Fastlane::Action

Fastlane::Action::AVAILABLE_CATEGORIES, Fastlane::Action::RETURN_TYPES

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, authors, deprecated_notes, lane_context, method_missing, other_action, output, return_type, return_value, sample_return_value, shell_out_should_use_bundle_exec?, step_text

Class Method Details

.authorObject



53
54
55
# File 'fastlane/lib/fastlane/actions/clean_build_artifacts.rb', line 53

def self.author
  "lmirosevic"
end

.available_optionsObject



31
32
33
34
35
36
37
38
39
# File 'fastlane/lib/fastlane/actions/clean_build_artifacts.rb', line 31

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

.categoryObject



67
68
69
# File 'fastlane/lib/fastlane/actions/clean_build_artifacts.rb', line 67

def self.category
  :misc
end

.descriptionObject



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

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

.detailsObject



45
46
47
48
49
50
51
# File 'fastlane/lib/fastlane/actions/clean_build_artifacts.rb', line 45

def self.details
  [
    "This action deletes the files that get created in your repo as a result of running the _gym_ and _sigh_ commands. It doesn't delete the `fastlane/report.xml` though, this is probably more suited for the .gitignore.",
    "",
    "Useful if you quickly want to send out a test build by dropping down to the command line and typing something like `fastlane beta`, without leaving your repo in a messy state afterwards."
  ].join("\n")
end

.example_codeObject



61
62
63
64
65
# File 'fastlane/lib/fastlane/actions/clean_build_artifacts.rb', line 61

def self.example_code
  [
    'clean_build_artifacts'
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:



57
58
59
# File 'fastlane/lib/fastlane/actions/clean_build_artifacts.rb', line 57

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
26
27
28
29
# File 'fastlane/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

  Actions.lane_context[Actions::SharedValues::SIGH_PROFILE_PATHS] = nil
  Actions.lane_context[Actions::SharedValues::DSYM_PATHS] = nil
  Actions.lane_context[Actions::SharedValues::DSYM_LATEST_UPLOADED_DATE] = nil

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