Class: Fastlane::Actions::AppsignerAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/appsigner/actions/appsigner_action.rb

Class Method Summary collapse

Class Method Details

.authorsObject



34
35
36
# File 'lib/fastlane/plugin/appsigner/actions/appsigner_action.rb', line 34

def self.authors
  ["Valeriy Makarshin"]
end

.available_optionsObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/fastlane/plugin/appsigner/actions/appsigner_action.rb', line 42

def self.available_options
  [
      FastlaneCore::ConfigItem.new(key: :domain,
                                   env_name: "APPSIGNER_DOMAIN",
                                   description: "The domain of your AppSigner service",
                                   optional: false,
                                   type: String,
                                   verify_block: proc do |value|
                                     UI.user_error!("No domain") if value.to_s.length == 0
                                   end),
      FastlaneCore::ConfigItem.new(key: :secret_key,
                                   env_name: "APPSIGNER_SECRET_KEY",
                                   description: "Secret key from AppSigner",
                                   optional: false,
                                   type: String,
                                   verify_block: proc do |value|
                                     UI.user_error!("No secret_key") if value.to_s.length == 0
                                   end),
      FastlaneCore::ConfigItem.new(key: :input_file,
                                   env_name: "APPSIGNER_INPUT_FILE",
                                   description: "The path to your apk/aab for sign",
                                   optional: false,
                                   type: String,
                                   verify_block: proc do |value|
                                     UI.user_error!("No input_file") if value.to_s.length == 0
                                   end),
      FastlaneCore::ConfigItem.new(key: :output_file,
                                   env_name: "APPSIGNER_OUTPUT_FILE",
                                   description: "Output apk/aab file. If you don't specify params, the plugin will override input file",
                                   optional: true,
                                   type: String,
                                   verify_block: proc do |value|
                                     UI.user_error!("No output_file") if value.to_s.length == 0
                                   end)
  ]
end

.descriptionObject



30
31
32
# File 'lib/fastlane/plugin/appsigner/actions/appsigner_action.rb', line 30

def self.description
  "AppSigner"
end

.detailsObject



38
39
40
# File 'lib/fastlane/plugin/appsigner/actions/appsigner_action.rb', line 38

def self.details
  "AppSigner"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


79
80
81
# File 'lib/fastlane/plugin/appsigner/actions/appsigner_action.rb', line 79

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

.run(params) ⇒ 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
# File 'lib/fastlane/plugin/appsigner/actions/appsigner_action.rb', line 4

def self.run(params)
  require 'net/http'
  require 'uri'
  uri = URI.parse('%s/api/v1/app/sign/' % params[:domain])

  header = {
      'X-SIGNER-SECRET': params[:secret_key],
      'Content-Disposition': 'inline; filename="%s"' % File.basename(params[:input_file]),
      'Content-Type': 'application/octet-stream'
  }
  request = Net::HTTP::Post.new(uri.request_uri, header)
  request.body = File.read(params[:input_file])
  response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
    http.request(request)
  end

  unless response.kind_of? Net::HTTPSuccess
    print("response.body = %s\n" % response.body)
    raise response.error!
  end
  output_file = params[:output_file] || params[:input_file]
  open(output_file, "wb") do |file|
    file.write(response.body)
  end
end