ocean_package 0.7.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e28f7f81431f3e160d1063694c6e2fcba7cffffdd9f5bb7fae4e7f9c54acb5d1
4
- data.tar.gz: 842dae0c668d80d20ad80d4b5b6fe1e3d0316d75b04ac5fbcb17cdb45afbdacf
3
+ metadata.gz: 1a4bc23aa666b52c1c5721d116d66b4b5d8e45e271546c4a1b40c9f293d86048
4
+ data.tar.gz: bb5a19d0acc1d8c61bf213d39942733ed53d3b3680d124c8c92bfee1a5fa5c38
5
5
  SHA512:
6
- metadata.gz: 2cc5adbe418c1827987f9db8273242ac486ae86f53cbcbc63d06d644067a7a69747d5e8854da81e49232f121842ae95efc5dcd1184ef05f5a560b026bde88678
7
- data.tar.gz: 2e46cd86d32aeeea542c4e9f4122121c70a4386eed5a3a23b097aae00146d846262b39229a2b30f5c4cb3670dc955c9ac888ba1e76c5bea9e2e4b361e3e371af
6
+ metadata.gz: d9322243e7b67e171b0d65f8b4b6ccdb7fb0ee4e3f977eae87941a7749934b1280e64fe222449bde23c1e756f14bace4314ee11775de285992f8079156fb5859
7
+ data.tar.gz: cd19248c665e3b5856870aa583bc6f28fb0b034d5e8b4b6324073923501df3b5d3fcaf4dff318a64c9cbbdcda69179dbe418ea35b10a9069076d52cbb1548665
@@ -16,11 +16,13 @@
16
16
  <orderEntry type="library" scope="PROVIDED" name="claide (v1.0.3, ruby-2.6.3-p62) [gem]" level="application" />
17
17
  <orderEntry type="library" scope="PROVIDED" name="concurrent-ruby (v1.1.6, ruby-2.6.3-p62) [gem]" level="application" />
18
18
  <orderEntry type="library" scope="PROVIDED" name="dingbot (v0.2.3, ruby-2.6.3-p62) [gem]" level="application" />
19
+ <orderEntry type="library" scope="PROVIDED" name="faraday (v1.0.1, ruby-2.6.3-p62) [gem]" level="application" />
19
20
  <orderEntry type="library" scope="PROVIDED" name="httparty (v0.18.1, ruby-2.6.3-p62) [gem]" level="application" />
20
21
  <orderEntry type="library" scope="PROVIDED" name="mime-types (v3.3.1, ruby-2.6.3-p62) [gem]" level="application" />
21
22
  <orderEntry type="library" scope="PROVIDED" name="mime-types-data (v3.2020.0512, ruby-2.6.3-p62) [gem]" level="application" />
22
23
  <orderEntry type="library" scope="PROVIDED" name="minitest (v5.11.3, ruby-2.6.3-p62) [gem]" level="application" />
23
24
  <orderEntry type="library" scope="PROVIDED" name="multi_xml (v0.6.0, ruby-2.6.3-p62) [gem]" level="application" />
25
+ <orderEntry type="library" scope="PROVIDED" name="multipart-post (v2.1.1, ruby-2.6.3-p62) [gem]" level="application" />
24
26
  <orderEntry type="library" scope="PROVIDED" name="rake (v10.5.0, ruby-2.6.3-p62) [gem]" level="application" />
25
27
  <orderEntry type="library" scope="PROVIDED" name="semantic_logger (v4.7.1, ruby-2.6.3-p62) [gem]" level="application" />
26
28
  </component>
data/Gemfile CHANGED
@@ -9,3 +9,4 @@ gem 'claide', '~> 1.0', '>= 1.0.3'
9
9
  gem 'dingbot'
10
10
  gem 'CFPropertyList'
11
11
  gem 'semantic_logger'
12
+ gem 'faraday'
@@ -1,7 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ocean_package (0.6.0)
4
+ ocean_package (0.8.0)
5
+ CFPropertyList
6
+ dingbot
7
+ faraday
8
+ multipart-post
9
+ semantic_logger
5
10
 
6
11
  GEM
7
12
  remote: https://rubygems.org/
@@ -11,6 +16,8 @@ GEM
11
16
  concurrent-ruby (1.1.6)
12
17
  dingbot (0.2.3)
13
18
  httparty
19
+ faraday (1.0.1)
20
+ multipart-post (>= 1.2, < 3)
14
21
  httparty (0.18.1)
15
22
  mime-types (~> 3.0)
16
23
  multi_xml (>= 0.5.2)
@@ -19,6 +26,7 @@ GEM
19
26
  mime-types-data (3.2020.0512)
20
27
  minitest (5.11.3)
21
28
  multi_xml (0.6.0)
29
+ multipart-post (2.1.1)
22
30
  rake (10.5.0)
23
31
  semantic_logger (4.7.1)
24
32
  concurrent-ruby (~> 1.0)
@@ -31,6 +39,7 @@ DEPENDENCIES
31
39
  bundler (~> 1.17.2)
32
40
  claide (~> 1.0, >= 1.0.3)
33
41
  dingbot
42
+ faraday
34
43
  minitest (~> 5.0)
35
44
  ocean_package!
36
45
  rake (~> 10.0)
data/README.md CHANGED
@@ -30,11 +30,16 @@ or
30
30
  - `ossutil`, [链接](https://help.aliyun.com/document_detail/120075.html?spm=a2c4g.11186623.2.45.6e491c7akyZ5HE)
31
31
 
32
32
 
33
+ ```
34
+ sudo gem install dingbot
35
+ sudo gem install semantic_logger
36
+ ```
37
+
33
38
 
34
39
  ## Usage
35
40
 
36
41
  ```
37
- oceanpackage --workspace-path=/Users/ocean/Desktop/code/iOS/MyApp.xcworkspace --scheme=MyApp --configuration=Debug --archive-path=/Users/ocean/Documents/myipas --export-options-plist=/Users/ocean/Desktop/code/iOS/Company/MyApp/AdHocExportOptions.plist --company-name=MyCompany --fir-token=fir平台的token --change-log=测试一下 --oss-bucket-name=bucket名称 --oss-bucket-path=bucket路径 --oss-endpoint=oss的endpoint --ding-token=钉钉群机器人token --at-mobiles=需要@的人手机号
42
+ oceanpackage --workspace-path=/Users/ocean/Desktop/code/iOS/MyApp.xcworkspace --scheme=MyApp --configuration=Debug --archive-path=/Users/ocean/Documents/myipas --export-options-plist=/Users/ocean/Desktop/code/iOS/Company/MyApp/AdHocExportOptions.plist --company-name=MyCompany --fir-token=fir平台的token --pgy-api-key=蒲公英平台的apikey --change-log=测试一下 --oss-bucket-name=bucket名称 --oss-bucket-path=bucket路径 --oss-endpoint=oss的endpoint --ding-token=钉钉群机器人token --at-mobiles=需要@的人手机号
38
43
  ```
39
44
 
40
45
  - `--workspace-path`: `.xcworkspace` 文件路径
@@ -44,6 +49,7 @@ oceanpackage --workspace-path=/Users/ocean/Desktop/code/iOS/MyApp.xcworkspace --
44
49
  - `--export-options-plist`: 打包用到的 `export-options` plist 文件路径
45
50
  - `--company-name`: 公司名称,可以不填
46
51
  - `--fir-token`: fir 平台的 token
52
+ - `--pgy-api-key`: 蒲公英平台的 api key
47
53
  - `--change-log`: 更新描述
48
54
  - `--oss-bucket-name`: `oss bucket` 名称
49
55
  - `--oss-bucket-path`: `oss bucket` 路径
@@ -2,6 +2,9 @@ require 'fileutils'
2
2
  require 'dingbot'
3
3
  require 'cfpropertylist'
4
4
  require 'semantic_logger'
5
+ require 'multipart_post'
6
+ require 'net/http/post/multipart'
7
+ require 'json'
5
8
 
6
9
  # 注意:这里使用 require_relative 来引用文件
7
10
  require_relative 'ocean_package/version'
@@ -14,6 +17,7 @@ require_relative 'ocean_package/dingtalk'
14
17
  require_relative 'ocean_package/ipa'
15
18
  require_relative 'ocean_package/logger'
16
19
  require_relative 'ocean_package/package'
20
+ require_relative 'ocean_package/pgy'
17
21
 
18
22
  module OceanPackage
19
23
  require 'claide'
@@ -26,16 +30,6 @@ module OceanPackage
26
30
  command = OceanPackage::Command.new(argvs)
27
31
  command.run
28
32
 
29
-
30
- # # command = OceanPackage::Command.new(config)
31
- #
32
- # argv = CLAide::ARGV.new(ARGV)
33
- # if !argv.arguments.include?("oceanpackage")
34
- # puts "不包含命令 oceanpackage"
35
- # exit 1
36
- # end
37
- #
38
- # puts "包含命令 oceanpackage"
39
33
  end
40
34
 
41
35
  end
@@ -6,6 +6,8 @@ module OceanPackage
6
6
  attr_accessor :package
7
7
  # fir 平台
8
8
  attr_accessor :fir
9
+ # 蒲公英平台
10
+ attr_accessor :pgy
9
11
  # oss 对象
10
12
  attr_accessor :oss
11
13
  # ding ding
@@ -56,6 +58,11 @@ module OceanPackage
56
58
  fir_log_path = @package.final_archive_path + 'fir.log'
57
59
  @fir = OceanPackage::Fir.new(fir_token, final_change_log, @package.ipa_file_path, fir_log_path)
58
60
 
61
+ ##### 蒲公英 #####
62
+ pgy_api_key = argv.option("pgy-api-key", "")
63
+ @pgy = OceanPackage::Pgy.new(pgy_api_key, final_change_log, @package.ipa_file_path)
64
+ Log.info("pgy_api_key: #{pgy_api_key}")
65
+
59
66
  ##### oss #####
60
67
  oss_bucket_name = argv.option("oss-bucket-name", "")
61
68
  Log.info("oss_bucket_name: #{oss_bucket_name}")
@@ -96,9 +103,22 @@ module OceanPackage
96
103
 
97
104
  # 上传 ipa 文件
98
105
  def upload
99
- upload_to_fir
106
+ can_fir = fir.check
107
+ can_pgy = pgy.check
108
+ if can_fir
109
+ Log.info("publish platform: fir")
110
+ upload_to_fir
111
+ elsif can_pgy
112
+ Log.info("publish platform: pgy")
113
+ upload_to_pgy
114
+ else
115
+ Log.info("publish platform: none, exit")
116
+ exit(1)
117
+ end
100
118
  end
101
119
 
120
+ # ------ fir 平台 -------
121
+
102
122
  # 上传到 fir 平台
103
123
  def upload_to_fir
104
124
  fir.run
@@ -112,6 +132,13 @@ module OceanPackage
112
132
  @qr_code_url = oss.upload(path, name)
113
133
  end
114
134
 
135
+ # ------ pgy 平台 -------
136
+ def upload_to_pgy
137
+ pgy.run
138
+ @qr_code_url = pgy.get_qr_code_url
139
+ @ipa_download_link = pgy.get_download_url
140
+ end
141
+
115
142
  # 总共时间,单位 秒 s
116
143
  def compute_total_time
117
144
  time1 = package.start_time
@@ -145,7 +172,9 @@ module OceanPackage
145
172
  content += "下载链接: [点我](#{@ipa_download_link})" + "\n\n"
146
173
  content += "![二维码](#{@qr_code_url})"
147
174
 
175
+ Log.divider
148
176
  Log.info("web hook message: \n#{content}")
177
+ Log.divider
149
178
 
150
179
  content
151
180
  end
@@ -17,6 +17,12 @@ module OceanPackage
17
17
  logger = Logger.new(STDOUT)
18
18
  logger.info("=========")
19
19
  end
20
+
21
+ # 换行
22
+ def Log.new_line
23
+ logger = Logger.new(STDOUT)
24
+ logger.info("\n")
25
+ end
20
26
  end
21
27
  end
22
28
 
@@ -60,6 +60,7 @@ module OceanPackage
60
60
  @end_time = Time.now
61
61
  # 返回打包成功的 ipa 文件路径
62
62
  ipa_file_path
63
+ open_ipa_file_path
63
64
  end
64
65
 
65
66
  # 一些校验
@@ -239,6 +240,13 @@ module OceanPackage
239
240
  # 也可以在该目录下查找 ipa 后缀的文件
240
241
  end
241
242
 
243
+ # 打开所在目录
244
+ def open_ipa_file_path
245
+ path = final_archive_path
246
+ open_cmd = "open #{path}"
247
+ system(open_cmd)
248
+ end
249
+
242
250
  end
243
251
 
244
252
  end
@@ -0,0 +1,148 @@
1
+
2
+ module OceanPackage
3
+ class Pgy
4
+ require 'multipart_post'
5
+ require 'net/http/post/multipart'
6
+ require 'json'
7
+
8
+ # # 用户Key,用来标识当前用户的身份
9
+ # attr_accessor :user_key
10
+ # API Key,用来识别API调用者的身份,如不特别说明,每个接口中都需要含有此参数。
11
+ attr_accessor :api_key
12
+ # # 表示一个App组的唯一Key。
13
+ # attr_accessor :app_key
14
+ # 更新日志
15
+ attr_accessor :change_log
16
+ # ipa文件包路径
17
+ attr_accessor :ipa_file_path
18
+
19
+ # 短链接
20
+ attr_accessor :short_url
21
+ # 二维码链接
22
+ attr_accessor :qr_code_url
23
+
24
+ # 初始化
25
+ def initialize(api_key, change_log, ipa_file_path)
26
+ @api_key = api_key
27
+ @change_log = change_log
28
+ @ipa_file_path = ipa_file_path
29
+ @short_url = ""
30
+ @qr_code_url = ""
31
+ end
32
+
33
+ # 校验
34
+ def check
35
+
36
+ # user_key_value = "#{@user_key}"
37
+ # if user_key_value.empty?
38
+ # Log.error("pgy user key is empty, please check !!!")
39
+ # return false
40
+ # end
41
+
42
+ api_key_value = "#{@api_key}"
43
+ if api_key_value.empty?
44
+ Log.error("pgy api key is empty, please check !!!")
45
+ return false
46
+ end
47
+
48
+ # app_key_value = "#{@app_key}"
49
+ # if app_key_value.empty?
50
+ # Log.error("pgy app key is empty, please check !!!")
51
+ # return false
52
+ # end
53
+
54
+ ipa_file_path_value = "#{@ipa_file_path}"
55
+ if ipa_file_path_value.empty?
56
+ Log.error("ipa file path is empty, please check !!!")
57
+ return false
58
+ end
59
+
60
+ return true
61
+ end
62
+
63
+ # 运行
64
+ def run
65
+ unless check
66
+ return
67
+ end
68
+ publish
69
+ end
70
+
71
+ # 上传
72
+ def publish
73
+ url = URI.parse('https://www.pgyer.com/apiv2/app/upload')
74
+ File.open("#{@ipa_file_path}") do |ipa|
75
+
76
+ # 构建必要的参数
77
+ ipa_file_name = Time.new.strftime("%Y-%m-%d_%H-%M-%S") + ".ipa"
78
+ require_params = {
79
+ "file" => UploadIO.new(ipa, "multipart/form-data", ipa_file_name),
80
+ "_api_key" => "#{@api_key}",
81
+ "buildUpdateDescription" => "#{@change_log}",
82
+ }
83
+
84
+ # 构造请求
85
+ req = Net::HTTP::Post::Multipart.new(url.path, require_params)
86
+
87
+ # 网络http
88
+ net = Net::HTTP.new(url.host, url.port)
89
+ # 这里需要设置,否则会有 EPIPE: Broken pipe 错误
90
+ net.use_ssl = true
91
+ net.verify_mode = OpenSSL::SSL::VERIFY_NONE
92
+ net.set_debug_output($stdout)
93
+
94
+ # 发起请求
95
+ res = net.start do |http|
96
+ http.use_ssl = true
97
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
98
+ http.request(req)
99
+ end
100
+
101
+ Log.divider
102
+ Log.info(res)
103
+
104
+ # 具体参考 https://www.pgyer.com/doc/view/api#paramInfo
105
+ case res
106
+ when Net::HTTPSuccess
107
+ # 响应是字符串类型,需要转为json进行处理
108
+ json_value = JSON.parse(res.body)
109
+ Log.divider
110
+ Log.info(json_value)
111
+ # 成功
112
+ data = json_value["data"]
113
+ short_url = data["buildShortcutUrl"]
114
+ qr_code_url = data["buildQRCodeURL"]
115
+ @short_url = short_url
116
+ @qr_code_url = qr_code_url
117
+ Log.error(@short_url)
118
+ Log.error(@qr_code_url)
119
+ else
120
+ # 失败
121
+ Log.error("pgy publish fail, please check !!!")
122
+ exit(1)
123
+ end
124
+ end
125
+ end
126
+
127
+ # 获取下载链接
128
+ def get_download_url
129
+ # 需要有固定的前缀
130
+ url = "https://www.pgyer.com/" + @short_url
131
+
132
+ Log.divider
133
+ Log.info(url)
134
+
135
+ url
136
+ end
137
+
138
+ # 获取二维码链接
139
+ def get_qr_code_url
140
+ url = "#{@qr_code_url}"
141
+
142
+ Log.divider
143
+ Log.info(url)
144
+
145
+ url
146
+ end
147
+ end
148
+ end
@@ -1,3 +1,3 @@
1
1
  module OceanPackage
2
- VERSION = "0.7.0"
2
+ VERSION = "0.9.0"
3
3
  end
@@ -37,6 +37,12 @@ Gem::Specification.new do |spec|
37
37
  spec.executables << 'oceanpackage'
38
38
  spec.require_paths = ["lib"]
39
39
 
40
+ spec.add_dependency 'dingbot'
41
+ spec.add_dependency 'CFPropertyList'
42
+ spec.add_dependency 'semantic_logger'
43
+ spec.add_dependency 'faraday'
44
+ spec.add_dependency 'multipart-post'
45
+
40
46
  spec.add_development_dependency "bundler", "~> 1.17.2"
41
47
  spec.add_development_dependency "rake", "~> 10.0"
42
48
  spec.add_development_dependency "minitest", "~> 5.0"
metadata CHANGED
@@ -1,15 +1,85 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ocean_package
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ocean
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-06 00:00:00.000000000 Z
11
+ date: 2020-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: dingbot
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: CFPropertyList
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: semantic_logger
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: faraday
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: multipart-post
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
13
83
  - !ruby/object:Gem::Dependency
14
84
  name: bundler
15
85
  requirement: !ruby/object:Gem::Requirement
@@ -89,6 +159,7 @@ files:
89
159
  - lib/ocean_package/logger.rb
90
160
  - lib/ocean_package/oss.rb
91
161
  - lib/ocean_package/package.rb
162
+ - lib/ocean_package/pgy.rb
92
163
  - lib/ocean_package/version.rb
93
164
  - ocean_package.gemspec
94
165
  homepage: https://github.com/oceanfive/ocean_package