class Escalator::Upload

Attributes

command[RW]
keyInfo_path[RW]
tmpdir[RW]

Public Class Methods

run(command) click to toggle source
# File lib/escalator/upload.rb, line 7
def run command
  @command = command
  prepareContext
  command.ipaPaths.each { |path|
    uploadIPA path
  }
end

Private Class Methods

prepareContext() click to toggle source
# File lib/escalator/upload.rb, line 23
def prepareContext
  Throw.note "Prepare upload context ..."
  @tmpdir = ENV["TMPDIR"] + "escalator/upload"
  if File.exist? tmpdir
    FileUtils.rm_rf Dir["#{tmpdir}/*"]
  else
    FileUtils.mkdir_p tmpdir
  end
  @keyInfo_path = tmpdir + "/keyInfo.json"
  keyInfo = Hash.new
  keyInfo[:in_house] = false
  keyInfo[:key_id] = command.key_id
  keyInfo[:issuer_id] = command.issuer_id
  keyInfo[:key_filepath] = command.keyfile_path
  keyInfo[:key] = File.read command.keyfile_path
  file = File.new keyInfo_path, "w"
  file.write JSON.generate keyInfo
  file.close
end
uploadIPA(path) click to toggle source
# File lib/escalator/upload.rb, line 43
def uploadIPA path
  Throw.note "Begin upload #{path} ..."
  cmd = "fastlane pilot upload --api_key_path #{keyInfo_path}"
  cmd += " -i #{path} -a #{command.bundle_identifier} -z true"
  system(cmd)
  if !$?.success?
    Throw.error "Upload ipa faild!"
  end
end