Class: Fastlane::Actions::FotaMailAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::FotaMailAction
- Defined in:
- lib/fastlane/plugin/polidea/actions/fota_mail.rb
Class Method Summary collapse
- .author ⇒ Object
- .available_options ⇒ Object
- .description ⇒ Object
- .inline_images(options) ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .mail_template(options) ⇒ Object
- .mailgunit(options) ⇒ Object
- .qr_code(installation_link) ⇒ Object
- .run(options) ⇒ Object
Class Method Details
.author ⇒ Object
103 104 105 |
# File 'lib/fastlane/plugin/polidea/actions/fota_mail.rb', line 103 def self. "thiagolioy" end |
.available_options ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 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 |
# File 'lib/fastlane/plugin/polidea/actions/fota_mail.rb', line 23 def self. [ FastlaneCore::ConfigItem.new(key: :postmaster, env_name: "MAILGUN_SANDBOX_POSTMASTER", description: "Mailgun sandbox domain postmaster for your mail"), FastlaneCore::ConfigItem.new(key: :apikey, env_name: "MAILGUN_APIKEY", description: "Mailgun apikey for your mail"), FastlaneCore::ConfigItem.new(key: :to, env_name: "MAILGUN_TO", description: "Destination of your mail"), FastlaneCore::ConfigItem.new(key: :from, env_name: "MAILGUN_FROM", optional: true, description: "Mailgun sender name", default_value: "Polidea"), FastlaneCore::ConfigItem.new(key: :success, env_name: "MAILGUN_SUCCESS", description: "Was this build successful? (true/false)", optional: true, default_value: true, is_string: false), FastlaneCore::ConfigItem.new(key: :ci_build_link, env_name: "MAILGUN_CI_BUILD_LINK", description: "CI Build Link", optional: true, is_string: true), FastlaneCore::ConfigItem.new(key: :template_path, env_name: "MAILGUN_TEMPLATE_PATH", description: "Mail HTML template", optional: true, is_string: true), FastlaneCore::ConfigItem.new(key: :platform, env_name: "MAILGUN_PLATFORM", description: "Platform used in mail template", optional: true, default_value: Actions.lane_context[Actions::SharedValues::PLATFORM_NAME]), FastlaneCore::ConfigItem.new(key: :app_icon, env_name: "MAILGUN_APP_ICON", description: "Path to app icon file", is_string: true, optional: true, default_value: Actions.lane_context[SharedValues::ICON_OUTPUT_PATH]), FastlaneCore::ConfigItem.new(key: :app_name, env_name: "MAILGUN_APP_NAME", description: "Application name", is_string: true, default_value: Actions.lane_context[SharedValues::APP_NAME]), FastlaneCore::ConfigItem.new(key: :app_version, env_name: "MAILGUN_APP_VERSION", description: "Application version", is_string: true, default_value: Actions.lane_context[SharedValues::APP_VERSION]), FastlaneCore::ConfigItem.new(key: :build_number, env_name: "MAILGUN_BUILD_NUMBER", description: "Build number", default_value: Actions.lane_context[SharedValues::BUILD_NUMBER]), FastlaneCore::ConfigItem.new(key: :installation_link, env_name: "MAILGUN_INSTALLATION_LINK", description: "Link to installation page", is_string: true, default_value: Actions.lane_context[SharedValues::S3_HTML_OUTPUT_PATH]), FastlaneCore::ConfigItem.new(key: :release_notes, env_name: "MAILGUN_RELEASE_NOTES", description: "Release notes", type: String, optional: true, default_value: Actions.lane_context[SharedValues::RELEASE_NOTES]), FastlaneCore::ConfigItem.new(key: :binary_size, env_name: "MAILGUN_BINARY_SIZE", description: "Binary size", type: Integer, default_value: Actions.lane_context[SharedValues::BINARY_SIZE]), FastlaneCore::ConfigItem.new(key: :inline, type: Array, optional: true, default_value: []) ] end |
.description ⇒ Object
19 20 21 |
# File 'lib/fastlane/plugin/polidea/actions/fota_mail.rb', line 19 def self.description "Send a success/error message to an email group" end |
.inline_images(options) ⇒ Object
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/fastlane/plugin/polidea/actions/fota_mail.rb', line 107 def self.inline_images() base_path = "#{__dir__}/../templates/images" [:inline] = [ qr_code([:installation_link]) ] [:inline] << File.new([:app_icon]) if [:app_icon] images = [ "polidea-facebook-icon.png", "polidea-github-icon.png", "polidea-logo.png", "polidea-twitter-icon.png" ] images << "icon-placeholder.png" unless [:app_icon] [:inline].concat(images.map { |image| File.new("#{base_path}/#{image}") }) end |
.is_supported?(platform) ⇒ Boolean
7 8 9 |
# File 'lib/fastlane/plugin/polidea/actions/fota_mail.rb', line 7 def self.is_supported?(platform) true end |
.mail_template(options) ⇒ Object
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 175 |
# File 'lib/fastlane/plugin/polidea/actions/fota_mail.rb', line 143 def self.mail_template() hash = { author: Actions., last_commit: Actions., is_android: [:platform] == :android, app_icon: [:app_icon] ? File.basename([:app_icon]) : nil, app_name: [:app_name], app_version: [:app_version], build_number: [:build_number], installation_link: [:installation_link], release_notes: ([:release_notes] || "").split("\n"), platform: [:platform], release_date: DateTime.now.strftime('%b %d, %Y'), binary_size: ([:binary_size] / 1024.0 / 1024.0).round(2).to_s } hash[:success] = [:success] hash[:ci_build_link] = [:ci_build_link] # grabs module eth = Fastlane::ErbTemplateHelper # create html from template html_template_path = [:template_path] if html_template_path && File.exist?(html_template_path) html_template = eth.load_from_path(html_template_path) else html_template = eth.load_from_path("#{__dir__}/../templates/mailgun_template.erb") end premailer = Premailer.new( eth.render(html_template, hash), { warn_level: Premailer::Warnings::SAFE, with_html_string: true } ) premailer.to_inline_css end |
.mailgunit(options) ⇒ Object
129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/fastlane/plugin/polidea/actions/fota_mail.rb', line 129 def self.mailgunit() sandbox_domain = [:postmaster].split("@").last body = mail_template() sh """curl -s --user 'api:#{[:apikey]}' \ https://api.mailgun.net/v3/#{sandbox_domain}/messages \ -F from='#{[:from]} <#{[:postmaster]}>' \ -F to='#{[:to]}' \ -F subject='#{[:app_name]} #{[:app_version]} (#{[:build_number]}) for #{[:platform]} is ready to install' \ --form-string html=#{Shellwords.escape(body)} \ """ + [:inline].map { |file| "-F inline=@#{file.path}" }.join(" "), print_command: false, print_command_output: false return body end |
.qr_code(installation_link) ⇒ Object
123 124 125 126 127 |
# File 'lib/fastlane/plugin/polidea/actions/fota_mail.rb', line 123 def self.qr_code(installation_link) qr_code_path = "/tmp/qr_code.png" QRGenerator.new(installation_link, false, ::ChunkyPNG::Color.rgb(103, 103, 103)).generate(qr_code_path) File.new(qr_code_path) end |
.run(options) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/fastlane/plugin/polidea/actions/fota_mail.rb', line 11 def self.run() Actions.verify_gem!('premailer') require 'premailer' inline_images() mailgunit() UI.success "Mail sent!" end |