Class: Fastlane::Actions::ZipAction

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

Constant Summary

Constants inherited from Fastlane::Action

Fastlane::Action::AVAILABLE_CATEGORIES

Documentation collapse

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, author, lane_context, method_missing, other_action, sample_return_value, sh, step_text

Class Method Details

.authorsObject



65
66
67
# File 'lib/fastlane/actions/zip.rb', line 65

def self.authors
  ["KrauseFx"]
end

.available_optionsObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/fastlane/actions/zip.rb', line 28

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :path,
                                 env_name: "FL_ZIP_PATH",
                                 description: "Path to the directory or file to be zipped",
                                 verify_block: proc do |value|
                                   UI.user_error!("Couldn't find file/folder at path '#{File.expand_path(value)}'") unless File.exist?(value)
                                 end),
    FastlaneCore::ConfigItem.new(key: :output_path,
                                 env_name: "FL_ZIP_OUTPUT_NAME",
                                 description: "The name of the resulting zip file",
                                 optional: true)
  ]
end

.categoryObject



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

def self.category
  :misc
end

.descriptionObject



21
22
23
# File 'lib/fastlane/actions/zip.rb', line 21

def self.description
  "Compress a file or folder to a zip"
end

.detailsObject



25
26
# File 'lib/fastlane/actions/zip.rb', line 25

def self.details
end

.example_codeObject



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

def self.example_code
  [
    'zip',
    'zip(
      path: "MyApp.app",
      output_path: "Latest.app.zip"
    )'
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


69
70
71
# File 'lib/fastlane/actions/zip.rb', line 69

def self.is_supported?(platform)
  true
end

.outputObject



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

def self.output
  []
end

.return_valueObject



61
62
63
# File 'lib/fastlane/actions/zip.rb', line 61

def self.return_value
  "The path to the output zip file"
end

.run(params) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/fastlane/actions/zip.rb', line 4

def self.run(params)
  UI.message "Compressing #{params[:path]}..."

  params[:output_path] ||= "#{params[:path]}.zip"

  Dir.chdir(File.expand_path("..", params[:path])) do # required to properly zip
    Actions.sh "zip -r #{params[:output_path].shellescape} #{File.basename(params[:path]).shellescape}"
  end

  UI.success "Successfully generated zip file at path '#{File.expand_path(params[:output_path])}'"
  return File.expand_path(params[:output_path])
end