Class: Fastlane::Actions::GetPushCertificateAction

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

Direct Known Subclasses

PemAction

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



28
29
30
# File 'fastlane/lib/fastlane/actions/get_push_certificate.rb', line 28

def self.author
  "KrauseFx"
end

.available_optionsObject



45
46
47
48
49
50
51
52
53
54
55
# File 'fastlane/lib/fastlane/actions/get_push_certificate.rb', line 45

def self.available_options
  require 'pem'
  require 'pem/options'

  @options = PEM::Options.available_options
  @options << FastlaneCore::ConfigItem.new(key: :new_profile,
                               description: "Block that is called if there is a new profile",
                               optional: true,
                               is_string: false)
  @options
end

.categoryObject



77
78
79
# File 'fastlane/lib/fastlane/actions/get_push_certificate.rb', line 77

def self.category
  :push
end

.descriptionObject



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

def self.description
  "Ensure a valid push profile is active, creating a new one if needed (via _pem_)"
end

.detailsObject



32
33
34
35
36
37
38
39
40
41
42
43
# File 'fastlane/lib/fastlane/actions/get_push_certificate.rb', line 32

def self.details
  [
    "Additionally to the available options, you can also specify a block that only gets executed if a new",
    "profile was created. You can use it to upload the new profile to your server.",
    "Use it like this: ",
    "get_push_certificate(",
    "  new_profile: proc do ",
    "    # your upload code",
    "  end",
    ")"
  ].join("\n")
end

.example_codeObject



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'fastlane/lib/fastlane/actions/get_push_certificate.rb', line 61

def self.example_code
  [
    'get_push_certificate',
    'pem # alias for "get_push_certificate"',
    'get_push_certificate(
      force: true, # create a new profile, even if the old one is still valid
      app_identifier: "net.sunapps.9", # optional app identifier,
      save_private_key: true,
      new_profile: proc do |profile_path| # this block gets called when a new profile was generated
        puts profile_path # the absolute path to the new PEM file
        # insert the code to upload the PEM file to the server
      end
    )'
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:



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

def self.is_supported?(platform)
  platform == :ios
end

.run(params) ⇒ Object



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

def self.run(params)
  require 'pem'
  require 'pem/options'
  require 'pem/manager'

  success_block = params[:new_profile]

  PEM.config = params

  if Helper.test?
    profile_path = './test.pem'
  else
    profile_path = PEM::Manager.start
  end

  if success_block && profile_path
    success_block.call(File.expand_path(profile_path)) if success_block
  end
end