Class: Fastlane::Actions::PolideaStoreAction

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

Documentation collapse

Class Method Summary collapse

Class Method Details

.authorObject



35
36
37
# File 'lib/fastlane/plugin/polidea/actions/polidea_store.rb', line 35

def self.author
  ["Piotrek Dubiel"]
end

.available_optionsObject



39
40
41
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/fastlane/plugin/polidea/actions/polidea_store.rb', line 39

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :api_token,
      env_name: "POLIDEA_STORE_API_TOKEN",
      description: "API Token for Polidea Store",
      verify_block: proc do |value|
        UI.user_error!("No API token for Polidea Store given, pass using `api_token: 'token'`") unless value and !value.empty?
      end),
    FastlaneCore::ConfigItem.new(key: :ipa,
      env_name: "",
      description: ".ipa file for the build ",
      optional: true,
      default_value: Actions.lane_context[SharedValues::IPA_OUTPUT_PATH]),
    FastlaneCore::ConfigItem.new(key: :apk,
      env_name: "",
      description: ".apk file for the build ",
      optional: true,
      default_value: Actions.lane_context[SharedValues::GRADLE_APK_OUTPUT_PATH]),
    FastlaneCore::ConfigItem.new(key: :plist_url,
      env_name: "POLIDEA_STORE_PLIST_URL",
      description: "Url to uploaded plist",
      default_value: Actions.lane_context[SharedValues::S3_PLIST_OUTPUT_PATH],
      verify_block: proc do |value|
        UI.user_error!("No plist url given, pass using `plist_url: 'url'` or make sure s3 action succeded and exposed S3_PLIST_OUTPUT_PATH shared value") unless value and !value.empty?
      end),
    FastlaneCore::ConfigItem.new(key: :apk_url,
      env_name: "POLIDEA_STORE_APK_URL",
      description: "Url to uploaded apk",
      default_value: Actions.lane_context[SharedValues::S3_APK_OUTPUT_PATH],
      verify_block: proc do |value|
        UI.user_error!("No apk url given, pass using `apk_url: 'url'` or make sure s3 action succeded and exposed S3_APK_OUTPUT_PATH shared value") unless value and !value.empty?
      end),
    FastlaneCore::ConfigItem.new(key: :icon_url,
      env_name: "POLIDEA_STORE_ICON_URL",
      description: "Url to uploaded app icon",
      default_value: Actions.lane_context[SharedValues::S3_ICON_OUTPUT_PATH],
      optional: true),
    FastlaneCore::ConfigItem.new(key: :release_notes,
      env_name: "",
      description: "Release notes to be attached to uploaded version",
      is_string: true,
      optional: true,
      default_value: Actions.lane_context[SharedValues::RELEASE_NOTES]),
    FastlaneCore::ConfigItem.new(key: :app_name,
      env_name: "",
      description: "Application name (defaults to results of extract_app_name action)",
      is_string: true,
      optional: true),
    FastlaneCore::ConfigItem.new(key: :bundle_id,
      env_name: "",
      description: "Bundle id, used if platform equals :ios",
      is_string: true,
      optional: true),
    FastlaneCore::ConfigItem.new(key: :bundle_version,
      env_name: "",
      description: "Bundle version, used if platform equals :ios",
      is_string: true,
      optional: true),
    FastlaneCore::ConfigItem.new(key: :package_name,
      env_name: "",
      description: "Package name, used if platform equals :android",
      is_string: true,
      optional: true),
    FastlaneCore::ConfigItem.new(key: :version_name,
      env_name: "",
      description: "Version name, used if platform equals :android",
      is_string: true,
      optional: true),
    FastlaneCore::ConfigItem.new(key: :version_code,
      env_name: "",
      description: "Version code, used if platform equals :android",
      type: Integer,
      optional: true),
    FastlaneCore::ConfigItem.new(key: :binary_size,
      env_name: "",
      description: ".ipa/.apk binary size in bytes",
      type: Integer,
      optional: true)
  ]
end

.descriptionObject



27
28
29
# File 'lib/fastlane/plugin/polidea/actions/polidea_store.rb', line 27

def self.description
  "Polidea Store upload action"
end

.detailsObject



31
32
33
# File 'lib/fastlane/plugin/polidea/actions/polidea_store.rb', line 31

def self.details
  "Notify Polidea Store about new app version"
end

.get_config(platform, params) ⇒ Object



136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/fastlane/plugin/polidea/actions/polidea_store.rb', line 136

def self.get_config(platform, params)
  binary_size = params[:binary_size] || Actions.lane_context[Actions::SharedValues::BINARY_SIZE]
  api_token = params[:api_token]
  icon_url = params[:icon_url]
  release_notes = params[:release_notes]

  case platform
  when :ios
    info = FastlaneCore::IpaFileAnalyser.fetch_info_plist_file(params[:ipa])
    app_name = params[:app_name] || info['CFBundleDisplayName'] || info['CFBundleName']
    app_identifier = params[:bundle_id] || info['CFBundleIdentifier']
    version = params[:bundle_version] || info['CFBundleShortVersionString']
    href = itms_href(params[:plist_url])
    url_scheme = get_url_scheme(info)
    UI.user_error!("No prefix scheme found in Info.plist. Make sure `add_prefix_schema` action succeded before build action") if url_scheme.nil?
  when :android
    manifest = Android::Apk.new(params[:apk]).manifest
    app_name = params[:app_name] || manifest.label
    app_identifier = params[:package_name] || manifest.package_name
    version = params[:version_name] || manifest.version_name
    version_code = params[:version_code] || manifest.version_code
    href = params[:apk_url]
  end

  config = {
    api_token: api_token,
    app_name: app_name,
    app_identifier: app_identifier,
    version: version,
    version_code: version_code,
    icon_url: icon_url,
    href: href,
    release_notes: release_notes,
    binary_size: binary_size,
    url_scheme: url_scheme
  }

  return config
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


120
121
122
# File 'lib/fastlane/plugin/polidea/actions/polidea_store.rb', line 120

def self.is_supported?(platform)
  [:ios, :android].include? platform
end

.run(params) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/fastlane/plugin/polidea/actions/polidea_store.rb', line 10

def self.run(params)
  platform = Actions.lane_context[Actions::SharedValues::PLATFORM_NAME].to_sym
  validate(platform, params)
  config = get_config(platform, params)
  app_name, app_identifier, version = notify(platform, config)

  UI.success("Successfully uploaded #{app_name} (#{app_identifier})")
  UI.success("version: #{version}")
  UI.success("using icon from #{params[:icon_url]}") if params[:icon_url]
  UI.success("using plist from #{params[:plist_url]}") if platform == :ios
  UI.success("with release notes: #{params[:release_notes]}") if params[:release_notes]
end

.validate(platform, params) ⇒ Object



124
125
126
127
128
129
130
131
132
133
134
# File 'lib/fastlane/plugin/polidea/actions/polidea_store.rb', line 124

def self.validate(platform, params)
  binary_size = params[:binary_size] || Actions.lane_context[Actions::SharedValues::BINARY_SIZE]
  UI.user_error!("No binary size given, pass using `binary_size: bytes` or make sure get_binary_size action succeded and exposed BINARY_SIZE shared value") unless binary_size and !binary_size.nil?

  case platform
  when :android
    UI.user_error!("No .apk file given, pass using `apk: 'apk path'` or make sure gradle action succeded and exposed GRADLE_APK_OUTPUT_PATH shared value") unless params[:apk] and !params[:apk].empty?
  when :ios
    UI.user_error!("No .ipa file given, pass using `ipa: 'ipa path'` or make sure gym action succeded and exposed IPA_OUTPUT_PATH shared value") unless params[:ipa] and !params[:ipa].empty?
  end
end