Class: Fastlane::Actions::ShuttleAction

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

Documentation collapse

Class Method Summary collapse

Class Method Details

.authorObject



45
46
47
# File 'lib/fastlane/plugin/polidea/actions/shuttle.rb', line 45

def self.author
  ["Piotrek Dubiel"]
end

.available_optionsObject



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
# File 'lib/fastlane/plugin/polidea/actions/shuttle.rb', line 49

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :api_token,
      env_name: "SHUTTLE_API_TOKEN",
      description: "API Token for Shuttle",
      verify_block: proc do |api_token|
        UI.user_error!("No API token for Shuttle given, pass using `api_token: 'token'`") unless api_token and !api_token.empty?
      end),
    FastlaneCore::ConfigItem.new(key: :plist_url,
      env_name: "SHUTTLE_PLIST_URL",
      description: "Url to uploaded plist",
      default_value: Actions.lane_context[SharedValues::S3_PLIST_OUTPUT_PATH],
      optional: true),
    FastlaneCore::ConfigItem.new(key: :prefix_schema,
      env_name: "SHUTTLE_PREFIX_SCHEMA",
      description: "Prefix schema in uploaded app",
      default_value: Actions.lane_context[SharedValues::PREFIX_SCHEMA],
      optional: true),
    FastlaneCore::ConfigItem.new(key: :apk_url,
      env_name: "SHUTTLE_APK_URL",
      description: "Url to uploaded apk",
      default_value: Actions.lane_context[SharedValues::S3_APK_OUTPUT_PATH],
      optional: true),
    FastlaneCore::ConfigItem.new(key: :app_identifier,
      description: "App identifier, either bundle id or package name",
      type: String,
      default_value: Actions.lane_context[SharedValues::APP_IDENTIFIER]),
    FastlaneCore::ConfigItem.new(key: :app_version,
      description: "App version, eg. '1.0.0''",
      type: String,
      default_value: Actions.lane_context[SharedValues::APP_VERSION]),
    FastlaneCore::ConfigItem.new(key: :build_number,
      description: "Build number, eg. 1337",
      is_string: false,
      default_value: Actions.lane_context[SharedValues::BUILD_NUMBER],
      verify_block: proc do |build_number|
        UI.user_error!("No value found for 'build_number'") unless build_number and build_number.kind_of? Integer
      end),
    FastlaneCore::ConfigItem.new(key: :binary_size,
      description: ".ipa/.apk binary size in bytes",
      is_string: false,
      default_value: Actions.lane_context[SharedValues::BINARY_SIZE],
      verify_block: proc do |binary_size|
        UI.user_error!("No value found for 'binary_size'") unless binary_size and binary_size.kind_of? Integer
      end),
    FastlaneCore::ConfigItem.new(key: :release_notes,
      description: "Release notes to be attached to uploaded version",
      type: String,
      optional: true,
      default_value: Actions.lane_context[SharedValues::RELEASE_NOTES]),
    FastlaneCore::ConfigItem.new(key: :releaser,
      description: "Releaser email",
      type: String,
      optional: true),
    FastlaneCore::ConfigItem.new(key: :environment,
      description: "Select environment, defaults to :production",
      type: Symbol,
      default_value: :production,
      optional: true)
  ]
end

.descriptionObject



37
38
39
# File 'lib/fastlane/plugin/polidea/actions/shuttle.rb', line 37

def self.description
  "Shuttle upload action"
end

.detailsObject



41
42
43
# File 'lib/fastlane/plugin/polidea/actions/shuttle.rb', line 41

def self.details
  "Notify Shuttle about new app version"
end

.get_config(platform, params) ⇒ Object



128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'lib/fastlane/plugin/polidea/actions/shuttle.rb', line 128

def self.get_config(platform, params)
  api_token = params[:api_token]
  app_identifier = params[:app_identifier]
  app_version = params[:app_version]
  build_number = params[:build_number]
  binary_size = params[:binary_size]
  release_notes = params[:release_notes]
  releaser = params[:releaser] || commit_author

  case platform
  when :ios
    href = itms_href(params[:plist_url])
    prefix_schema = params[:prefix_schema]
  when :android
    href = params[:apk_url]
  end

  {
    api_token: api_token,
    app_identifier: app_identifier,
    app_version: app_version,
    build_number: build_number,
    href: href,
    release_notes: release_notes,
    releaser: releaser,
    binary_size: binary_size,
    prefix_schema: prefix_schema,
    environment: params[:environment]
  }
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


111
112
113
# File 'lib/fastlane/plugin/polidea/actions/shuttle.rb', line 111

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

.run(params) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/fastlane/plugin/polidea/actions/shuttle.rb', line 8

def self.run(params)
  Fastlane::Polidea.session.action_launched("shuttle", params)
  platform = Actions.lane_context[Actions::SharedValues::PLATFORM_NAME].to_sym
  options = {
    api_token: params[:api_token],
    plist_url: params[:plist_url],
    prefix_schema: params[:prefix_schema],
    apk_url: params[:apk_url],
    app_identifier: params[:app_identifier],
    app_version: params[:app_version],
    build_number: params[:build_number],
    binary_size: params[:binary_size],
    release_notes: params[:release_notes],
    releaser: params[:releaser],
    environment: params[:environment]
  }
  validate(platform, options)
  config = get_config(platform, options)
  notify(platform, config)

  UI.success("Successfully uploaded to #{params[:app_identifier]} #{params[:app_version]}.#{params[:build_number]} to Shuttle")

  Fastlane::Polidea.session.action_completed("shuttle")
end

.validate(platform, params) ⇒ Object



115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/fastlane/plugin/polidea/actions/shuttle.rb', line 115

def self.validate(platform, params)
  case platform
  when :android
    apk_url = params[:apk_url]
    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 apk_url and !apk_url.empty?
  when :ios
    plist_url = params[:plist_url]
    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 plist_url and !plist_url.empty?
    url_scheme = params[:prefix_schema]
    UI.user_error!("No prefix scheme given. Make sure `add_prefix_schema` action succeded before build action") if url_scheme.nil?
  end
end