Class: OceanPackage::Command
- Inherits:
-
Object
- Object
- OceanPackage::Command
- Defined in:
- lib/ocean_package/command.rb
Instance Attribute Summary collapse
-
#arguments ⇒ Object
命令参数.
-
#at_mobiles ⇒ Object
@ 的手机号.
-
#change_log ⇒ Object
本次更新内容.
-
#ding ⇒ Object
ding ding.
-
#fir ⇒ Object
fir 平台.
-
#oss ⇒ Object
oss 对象.
-
#package ⇒ Object
xcodebuild 打包相关.
Instance Method Summary collapse
-
#compute_total_time ⇒ Object
总共时间,单位 秒 s.
-
#final_change_log ⇒ Object
最终的 change log.
-
#finished ⇒ Object
打包完成.
-
#initialize(params = []) ⇒ Command
constructor
A new instance of Command.
-
#make_web_hook_message ⇒ Object
web hook 消息内容.
-
#make_web_hook_message_title ⇒ Object
web hook 消息标题.
- #run ⇒ Object
-
#send_ding_talk_msg ⇒ Object
发送打包信息到钉钉.
-
#upload ⇒ Object
上传 ipa 文件.
-
#upload_qr_code(path, name) ⇒ Object
上传 二维码 QRCode 图片到 oss 后续其他平台,比如蒲公英也是需要类似的逻辑.
-
#upload_to_fir ⇒ Object
上传到 fir 平台.
Constructor Details
#initialize(params = []) ⇒ Command
Returns a new instance of Command.
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 |
# File 'lib/ocean_package/command.rb', line 23 def initialize(params = []) argv = CLAide::ARGV.new(params) @arguments = argv.arguments Log.info("arguments: #{@arguments}") workspace_path = argv.option("workspace-path", "") Log.info("workspace_path: #{workspace_path}") scheme = argv.option("scheme", "") Log.info("scheme: #{scheme}") configuration = argv.option("configuration", OceanPackage::Constants::DEFAULT_CONFIGURATION) Log.info("configuration: #{configuration}") archive_path = argv.option("archive-path", OceanPackage::Constants::DEFAULT_ARCHIVE_PATH) Log.info("archive_path: #{archive_path}") company_name = argv.option("company-name", OceanPackage::Constants::DEFAULT_COMPANY_NAME) Log.info("company_name: #{company_name}") = argv.option("export-options-plist", "") Log.info("export_options_plist: #{export_options_plist}") @package = OceanPackage::Package.new(workspace_path, scheme, configuration, archive_path, company_name, ) fir_token = argv.option("fir-token", "") Log.info("fir_token: #{fir_token}") change_log = argv.option("change-log", "") @change_log = change_log Log.info("change_log: #{change_log}") fir_log_path = @package.final_archive_path + 'fir.log' @fir = OceanPackage::Fir.new(fir_token, final_change_log, @package.ipa_file_path, fir_log_path) ##### oss ##### oss_bucket_name = argv.option("oss-bucket-name", "") Log.info("oss_bucket_name: #{oss_bucket_name}") oss_bucket_path = argv.option("oss-bucket-path", "") Log.info("oss_bucket_path: #{oss_bucket_path}") oss_endpoint = argv.option("oss-endpoint", "") Log.info("oss_endpoint: #{oss_endpoint}") @oss = OceanPackage::Oss.new(oss_bucket_name, oss_bucket_path, oss_endpoint) ding_token = argv.option("ding-token", "") Log.info("ding_token: #{ding_token}") at_mobiles = argv.option("at-mobiles", "").split(",") Log.info("ding_at_mobiles: #{at_mobiles}") @at_mobiles = at_mobiles @ding = OceanPackage::DingTalk.new(ding_token) end |
Instance Attribute Details
#arguments ⇒ Object
命令参数
15 16 17 |
# File 'lib/ocean_package/command.rb', line 15 def arguments @arguments end |
#at_mobiles ⇒ Object
@ 的手机号
21 22 23 |
# File 'lib/ocean_package/command.rb', line 21 def at_mobiles @at_mobiles end |
#change_log ⇒ Object
本次更新内容
18 19 20 |
# File 'lib/ocean_package/command.rb', line 18 def change_log @change_log end |
#ding ⇒ Object
ding ding
12 13 14 |
# File 'lib/ocean_package/command.rb', line 12 def ding @ding end |
#fir ⇒ Object
fir 平台
8 9 10 |
# File 'lib/ocean_package/command.rb', line 8 def fir @fir end |
#oss ⇒ Object
oss 对象
10 11 12 |
# File 'lib/ocean_package/command.rb', line 10 def oss @oss end |
#package ⇒ Object
xcodebuild 打包相关
6 7 8 |
# File 'lib/ocean_package/command.rb', line 6 def package @package end |
Instance Method Details
#compute_total_time ⇒ Object
总共时间,单位 秒 s
116 117 118 119 120 121 122 123 124 |
# File 'lib/ocean_package/command.rb', line 116 def compute_total_time time1 = package.start_time time2 = Time.now seconds = time2 - time1 Log.info("total time: #{seconds}") seconds end |
#final_change_log ⇒ Object
最终的 change log
82 83 84 85 86 87 88 |
# File 'lib/ocean_package/command.rb', line 82 def final_change_log if @change_log.empty? syscall('git log --pretty=format:%s -1') else @change_log end end |
#finished ⇒ Object
打包完成
164 165 166 167 168 |
# File 'lib/ocean_package/command.rb', line 164 def finished Log.divider Log.info("package finished") Log.divider end |
#make_web_hook_message ⇒ Object
web hook 消息内容
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/ocean_package/command.rb', line 132 def ipa = OceanPackage::Ipa.new(package.ipa_file_path) ipa.run # markdown 格式 content = "# #{ipa.display_name} \n\n" content += "当前平台: iOS \n\n" content += "APP名称: " + ipa.display_name + "\n\n" content += "当前版本: " + ipa.version + "(#{ipa.build_version})" + "\n\n" content += "打包耗时: " + "#{compute_total_time}" + "s" + "\n\n" content += "发布环境: " + "#{package.configuration}" + "\n\n" content += "更新描述: " + final_change_log + "\n\n" content += "发布时间: " + Time.new.strftime("%Y年%m月%d日 %H时%M分%S秒") + "\n\n" content += "下载链接: [点我](#{@ipa_download_link})" + "\n\n" content += "" Log.info("web hook message: \n#{content}") content end |
#make_web_hook_message_title ⇒ Object
web hook 消息标题
127 128 129 |
# File 'lib/ocean_package/command.rb', line 127 def "iOS 来新包啦~" end |
#run ⇒ Object
90 91 92 93 94 95 |
# File 'lib/ocean_package/command.rb', line 90 def run package.run upload send_ding_talk_msg finished end |
#send_ding_talk_msg ⇒ Object
发送打包信息到钉钉
154 155 156 157 158 159 160 161 |
# File 'lib/ocean_package/command.rb', line 154 def send_ding_talk_msg # 消息卡片,富文本 title = content = ding.(title, content) ding.(title, @at_mobiles) end |
#upload ⇒ Object
上传 ipa 文件
98 99 100 |
# File 'lib/ocean_package/command.rb', line 98 def upload upload_to_fir end |
#upload_qr_code(path, name) ⇒ Object
上传 二维码 QRCode 图片到 oss 后续其他平台,比如蒲公英也是需要类似的逻辑
111 112 113 |
# File 'lib/ocean_package/command.rb', line 111 def upload_qr_code(path, name) @qr_code_url = oss.upload(path, name) end |
#upload_to_fir ⇒ Object
上传到 fir 平台
103 104 105 106 107 |
# File 'lib/ocean_package/command.rb', line 103 def upload_to_fir fir.run upload_qr_code(fir.find_qr_code_path, fir.find_release_id) @ipa_download_link = fir.whole_download_link end |