Class: Fastlane::Actions::ZipAction

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

Documentation collapse

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, author, method_missing, other_action, sh, step_text

Class Method Details

.authorsObject



51
52
53
# File 'lib/fastlane/actions/zip.rb', line 51

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

.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

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/fastlane/actions/zip.rb', line 55

def self.is_supported?(platform)
  true
end

.outputObject



43
44
45
# File 'lib/fastlane/actions/zip.rb', line 43

def self.output
  []
end

.return_valueObject



47
48
49
# File 'lib/fastlane/actions/zip.rb', line 47

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