ocean_package 0.5.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.idea/ocean_package.iml +3 -1
- data/Gemfile +1 -0
- data/Gemfile.lock +10 -1
- data/README.md +8 -1
- data/lib/ocean_package.rb +6 -12
- data/lib/ocean_package/command.rb +64 -6
- data/lib/ocean_package/fir.rb +34 -21
- data/lib/ocean_package/logger.rb +6 -0
- data/lib/ocean_package/package.rb +39 -3
- data/lib/ocean_package/pgy.rb +149 -0
- data/lib/ocean_package/version.rb +1 -1
- data/ocean_package.gemspec +6 -0
- metadata +73 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df5f1fd000b7d02b3625d23d9c84b75bde227f1675739c743cd8c1147905ce4f
|
4
|
+
data.tar.gz: e59dfeff667bb1d68c95f3cd2c03da8f9d5a10a2b3894b763c8c41763460d820
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e3db7f612b4b0639f58caa093769306c43a3b99874d735948dd192b98578f64816c6768d620cc2f6d08ff9af24c6b9e7fe7e124b3ccbc3c8c2cea1b4eeb8675
|
7
|
+
data.tar.gz: 727f0b9332fff05106eff0d660646408b74f2ceea3d905f93344921897e50e42ce3a5f239229c1a9bac1e8e084db3c5740d2695257ec4e36397d340e0366e592
|
data/.idea/ocean_package.iml
CHANGED
@@ -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
|
-
<orderEntry type="library" scope="PROVIDED" name="minitest (v5.
|
23
|
+
<orderEntry type="library" scope="PROVIDED" name="minitest (v5.12.0, 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
data/Gemfile.lock
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
ocean_package (0.
|
4
|
+
ocean_package (0.10.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,17 @@ 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
|
+
sudo gem install multipart-post
|
37
|
+
```
|
38
|
+
|
33
39
|
|
34
40
|
## Usage
|
35
41
|
|
36
42
|
```
|
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=需要@的人手机号
|
43
|
+
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
44
|
```
|
39
45
|
|
40
46
|
- `--workspace-path`: `.xcworkspace` 文件路径
|
@@ -44,6 +50,7 @@ oceanpackage --workspace-path=/Users/ocean/Desktop/code/iOS/MyApp.xcworkspace --
|
|
44
50
|
- `--export-options-plist`: 打包用到的 `export-options` plist 文件路径
|
45
51
|
- `--company-name`: 公司名称,可以不填
|
46
52
|
- `--fir-token`: fir 平台的 token
|
53
|
+
- `--pgy-api-key`: 蒲公英平台的 api key
|
47
54
|
- `--change-log`: 更新描述
|
48
55
|
- `--oss-bucket-name`: `oss bucket` 名称
|
49
56
|
- `--oss-bucket-path`: `oss bucket` 路径
|
data/lib/ocean_package.rb
CHANGED
@@ -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,28 +17,19 @@ 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'
|
20
24
|
|
21
25
|
def self.run(argvs)
|
22
|
-
puts "
|
26
|
+
puts "=========ARGV========="
|
23
27
|
puts ARGV
|
24
|
-
puts "
|
28
|
+
puts "=========ARGV========="
|
25
29
|
|
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
|
@@ -20,6 +22,9 @@ module OceanPackage
|
|
20
22
|
# @ 的手机号
|
21
23
|
attr_accessor :at_mobiles
|
22
24
|
|
25
|
+
# 自定义的ipa文件路径
|
26
|
+
attr_accessor :custom_ipa_file_path
|
27
|
+
|
23
28
|
def initialize(params = [])
|
24
29
|
argv = CLAide::ARGV.new(params)
|
25
30
|
|
@@ -32,7 +37,8 @@ module OceanPackage
|
|
32
37
|
scheme = argv.option("scheme", "")
|
33
38
|
Log.info("scheme: #{scheme}")
|
34
39
|
|
35
|
-
|
40
|
+
# 默认配置改为空,防止包环境错误
|
41
|
+
configuration = argv.option("configuration", "")
|
36
42
|
Log.info("configuration: #{configuration}")
|
37
43
|
|
38
44
|
archive_path = argv.option("archive-path", OceanPackage::Constants::DEFAULT_ARCHIVE_PATH)
|
@@ -44,7 +50,18 @@ module OceanPackage
|
|
44
50
|
export_options_plist = argv.option("export-options-plist", "")
|
45
51
|
Log.info("export_options_plist: #{export_options_plist}")
|
46
52
|
|
47
|
-
|
53
|
+
##### 自定义的 ipa 文件 #####
|
54
|
+
ipa_file_path = argv.option("ipa-file-path", "")
|
55
|
+
Log.info("ipa_file_path: #{ipa_file_path}")
|
56
|
+
@custom_ipa_file_path = ipa_file_path
|
57
|
+
|
58
|
+
extra_export_params = argv.option("extra-export-params", "")
|
59
|
+
Log.info("extra-export-params: #{extra_export_params}")
|
60
|
+
|
61
|
+
# 自定义ipa文件,使用该文件作为 archive path
|
62
|
+
tmp_archive_path = has_custom_ipa_file ? File.dirname("#{ipa_file_path}") : archive_path
|
63
|
+
Log.info("tmp_archive_path: #{tmp_archive_path}")
|
64
|
+
@package = OceanPackage::Package.new(workspace_path, scheme, configuration, tmp_archive_path, company_name, export_options_plist, extra_export_params)
|
48
65
|
|
49
66
|
fir_token = argv.option("fir-token", "")
|
50
67
|
Log.info("fir_token: #{fir_token}")
|
@@ -54,7 +71,12 @@ module OceanPackage
|
|
54
71
|
Log.info("change_log: #{change_log}")
|
55
72
|
|
56
73
|
fir_log_path = @package.final_archive_path + 'fir.log'
|
57
|
-
@fir = OceanPackage::Fir.new(fir_token, final_change_log,
|
74
|
+
@fir = OceanPackage::Fir.new(fir_token, final_change_log, final_ipa_file_path, fir_log_path)
|
75
|
+
|
76
|
+
##### 蒲公英 #####
|
77
|
+
pgy_api_key = argv.option("pgy-api-key", "")
|
78
|
+
@pgy = OceanPackage::Pgy.new(pgy_api_key, final_change_log, final_ipa_file_path)
|
79
|
+
Log.info("pgy_api_key: #{pgy_api_key}")
|
58
80
|
|
59
81
|
##### oss #####
|
60
82
|
oss_bucket_name = argv.option("oss-bucket-name", "")
|
@@ -87,8 +109,22 @@ module OceanPackage
|
|
87
109
|
end
|
88
110
|
end
|
89
111
|
|
112
|
+
# 是否设置了自定义的ipa文件
|
113
|
+
def has_custom_ipa_file
|
114
|
+
"#{@custom_ipa_file_path}".empty? ? false : true
|
115
|
+
end
|
116
|
+
|
117
|
+
# 最终的ipa文件路径
|
118
|
+
def final_ipa_file_path
|
119
|
+
has_custom_ipa_file ? "#{@custom_ipa_file_path}" : @package.ipa_file_path
|
120
|
+
end
|
121
|
+
|
122
|
+
# 运行
|
90
123
|
def run
|
91
|
-
|
124
|
+
# 没有自定义ipa文件,需要执行打包命令
|
125
|
+
unless has_custom_ipa_file
|
126
|
+
package.run
|
127
|
+
end
|
92
128
|
upload
|
93
129
|
send_ding_talk_msg
|
94
130
|
finished
|
@@ -96,9 +132,22 @@ module OceanPackage
|
|
96
132
|
|
97
133
|
# 上传 ipa 文件
|
98
134
|
def upload
|
99
|
-
|
135
|
+
can_fir = fir.check
|
136
|
+
can_pgy = pgy.check
|
137
|
+
if can_fir
|
138
|
+
Log.info("publish platform: fir")
|
139
|
+
upload_to_fir
|
140
|
+
elsif can_pgy
|
141
|
+
Log.info("publish platform: pgy")
|
142
|
+
upload_to_pgy
|
143
|
+
else
|
144
|
+
Log.info("publish platform: none, exit")
|
145
|
+
exit(1)
|
146
|
+
end
|
100
147
|
end
|
101
148
|
|
149
|
+
# ------ fir 平台 -------
|
150
|
+
|
102
151
|
# 上传到 fir 平台
|
103
152
|
def upload_to_fir
|
104
153
|
fir.run
|
@@ -112,6 +161,13 @@ module OceanPackage
|
|
112
161
|
@qr_code_url = oss.upload(path, name)
|
113
162
|
end
|
114
163
|
|
164
|
+
# ------ pgy 平台 -------
|
165
|
+
def upload_to_pgy
|
166
|
+
pgy.run
|
167
|
+
@qr_code_url = pgy.get_qr_code_url
|
168
|
+
@ipa_download_link = pgy.get_download_url
|
169
|
+
end
|
170
|
+
|
115
171
|
# 总共时间,单位 秒 s
|
116
172
|
def compute_total_time
|
117
173
|
time1 = package.start_time
|
@@ -130,7 +186,7 @@ module OceanPackage
|
|
130
186
|
|
131
187
|
# web hook 消息内容
|
132
188
|
def make_web_hook_message
|
133
|
-
ipa = OceanPackage::Ipa.new(
|
189
|
+
ipa = OceanPackage::Ipa.new(final_ipa_file_path)
|
134
190
|
ipa.run
|
135
191
|
|
136
192
|
# markdown 格式
|
@@ -145,7 +201,9 @@ module OceanPackage
|
|
145
201
|
content += "下载链接: [点我](#{@ipa_download_link})" + "\n\n"
|
146
202
|
content += "![二维码](#{@qr_code_url})"
|
147
203
|
|
204
|
+
Log.divider
|
148
205
|
Log.info("web hook message: \n#{content}")
|
206
|
+
Log.divider
|
149
207
|
|
150
208
|
content
|
151
209
|
end
|
data/lib/ocean_package/fir.rb
CHANGED
@@ -37,11 +37,12 @@ module OceanPackage
|
|
37
37
|
|
38
38
|
# 命令:上传ipa文件到fir平台
|
39
39
|
def publish_cmd
|
40
|
+
# @ipa_file_path @change_log @log_path 需要是字符串值!!!!!
|
40
41
|
cmd = "fir publish"
|
41
|
-
cmd += " " + "#{@ipa_file_path}"
|
42
|
-
cmd += " -c " + "#{@change_log}"
|
42
|
+
cmd += " " + "'#{@ipa_file_path}'"
|
43
|
+
cmd += " -c " + "'#{@change_log}'"
|
43
44
|
cmd += " -Q"
|
44
|
-
cmd += " | tee " + "#{@log_path}"
|
45
|
+
cmd += " | tee " + "'#{@log_path}'"
|
45
46
|
|
46
47
|
Log.divider
|
47
48
|
Log.info("fir publish command: #{cmd}")
|
@@ -109,14 +110,18 @@ module OceanPackage
|
|
109
110
|
# 正则表达式匹配
|
110
111
|
pattern = /.*Release id is.*/
|
111
112
|
release_id = ''
|
112
|
-
File.
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
113
|
+
if File.exist?("#{@log_path}")
|
114
|
+
File.open(@log_path, "r") do |f|
|
115
|
+
f.each_line do |line|
|
116
|
+
line_s = "#{line}"
|
117
|
+
if line_s =~ pattern
|
118
|
+
release_id = line_s.split(' ').last
|
119
|
+
break
|
120
|
+
end
|
118
121
|
end
|
119
122
|
end
|
123
|
+
else
|
124
|
+
Log.info("fir log path not exist !!!")
|
120
125
|
end
|
121
126
|
Log.info("fir release id value: #{release_id}")
|
122
127
|
release_id
|
@@ -127,14 +132,18 @@ module OceanPackage
|
|
127
132
|
# 正则表达式匹配
|
128
133
|
pattern = /.*Published succeed:.*/
|
129
134
|
link = ''
|
130
|
-
File.
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
135
|
+
if File.exist?("#{@log_path}")
|
136
|
+
File.open(@log_path, "r") do |f|
|
137
|
+
f.each_line do |line|
|
138
|
+
line_s = "#{line}"
|
139
|
+
if line_s =~ pattern
|
140
|
+
link = line_s.split(' ').last
|
141
|
+
break
|
142
|
+
end
|
136
143
|
end
|
137
144
|
end
|
145
|
+
else
|
146
|
+
Log.info("fir log path not exist !!!")
|
138
147
|
end
|
139
148
|
Log.info("fir link value: #{link}")
|
140
149
|
link
|
@@ -156,14 +165,18 @@ module OceanPackage
|
|
156
165
|
# 正则表达式匹配
|
157
166
|
pattern = /.*Local qrcode file:.*/
|
158
167
|
path = ''
|
159
|
-
File.
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
168
|
+
if File.exist?("#{@log_path}")
|
169
|
+
File.open(@log_path, "r") do |f|
|
170
|
+
f.each_line do |line|
|
171
|
+
line_s = "#{line}"
|
172
|
+
if line_s =~ pattern
|
173
|
+
path = line_s.split(' ').last
|
174
|
+
break
|
175
|
+
end
|
165
176
|
end
|
166
177
|
end
|
178
|
+
else
|
179
|
+
Log.info("fir log path not exist !!!")
|
167
180
|
end
|
168
181
|
Log.info("fir qr code path value: #{path}")
|
169
182
|
path
|
data/lib/ocean_package/logger.rb
CHANGED
@@ -9,6 +9,8 @@ module OceanPackage
|
|
9
9
|
attr_accessor :scheme
|
10
10
|
# 配置信息: Debug, Release
|
11
11
|
attr_accessor :configuration
|
12
|
+
# 额外的打底参数,比如对buildsettings进行重写
|
13
|
+
attr_accessor :extra_export_params
|
12
14
|
|
13
15
|
# archive 归档路径
|
14
16
|
attr_accessor :archive_path
|
@@ -25,7 +27,7 @@ module OceanPackage
|
|
25
27
|
# 结束时间
|
26
28
|
attr_accessor :end_time
|
27
29
|
|
28
|
-
def initialize(workspace_path, scheme, configuration, archive_path, company_name, export_options_plist)
|
30
|
+
def initialize(workspace_path, scheme, configuration, archive_path, company_name, export_options_plist, extra_export_params)
|
29
31
|
@workspace_path = workspace_path
|
30
32
|
@scheme = scheme
|
31
33
|
@configuration = configuration
|
@@ -33,6 +35,10 @@ module OceanPackage
|
|
33
35
|
@company_name = company_name
|
34
36
|
@date_time = Time.new.strftime("%Y-%m-%d_%H-%M-%S")
|
35
37
|
@export_options_plist = export_options_plist
|
38
|
+
@extra_export_params = extra_export_params
|
39
|
+
|
40
|
+
# 预设置开始时间
|
41
|
+
@start_time = Time.now
|
36
42
|
end
|
37
43
|
|
38
44
|
# workspace 的路径
|
@@ -53,13 +59,18 @@ module OceanPackage
|
|
53
59
|
# 执行打包相关命令
|
54
60
|
def run
|
55
61
|
@start_time = Time.now
|
62
|
+
# 检查必须参数
|
56
63
|
check
|
64
|
+
# clean 项目
|
57
65
|
clean
|
66
|
+
# 打包项目
|
58
67
|
archive
|
68
|
+
# 导出 ipa 包
|
59
69
|
export
|
60
70
|
@end_time = Time.now
|
61
71
|
# 返回打包成功的 ipa 文件路径
|
62
72
|
ipa_file_path
|
73
|
+
open_ipa_file_path
|
63
74
|
end
|
64
75
|
|
65
76
|
# 一些校验
|
@@ -144,12 +155,19 @@ module OceanPackage
|
|
144
155
|
# 最终的打包路径
|
145
156
|
def final_archive_path
|
146
157
|
path = processed_archive_path
|
147
|
-
|
148
|
-
|
158
|
+
unless "#{@company_name}".empty?
|
159
|
+
path += @company_name + '/'
|
160
|
+
end
|
161
|
+
unless "#{project_name}".empty?
|
162
|
+
path += project_name + '/'
|
163
|
+
end
|
149
164
|
path += @date_time + '/'
|
150
165
|
|
151
166
|
Log.info("final archive path: #{path}")
|
152
167
|
|
168
|
+
# 不存在,需要进行创建,外部传入了 ipa 文件的情况
|
169
|
+
FileUtils.mkdir_p(path)
|
170
|
+
|
153
171
|
path
|
154
172
|
end
|
155
173
|
|
@@ -204,6 +222,17 @@ module OceanPackage
|
|
204
222
|
cmd += ' -exportPath ' + final_archive_path
|
205
223
|
cmd += ' -exportOptionsPlist ' + @export_options_plist
|
206
224
|
|
225
|
+
unless "#{@extra_export_params}".empty?
|
226
|
+
# 分割
|
227
|
+
params = "#{@extra_export_params}".split(",")
|
228
|
+
# 再拼接
|
229
|
+
joined_string = params.join(" ")
|
230
|
+
|
231
|
+
unless joined_string.empty?
|
232
|
+
cmd += ' ' + joined_string
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
207
236
|
Log.divider
|
208
237
|
Log.info("export command: #{cmd}")
|
209
238
|
Log.divider
|
@@ -239,6 +268,13 @@ module OceanPackage
|
|
239
268
|
# 也可以在该目录下查找 ipa 后缀的文件
|
240
269
|
end
|
241
270
|
|
271
|
+
# 打开所在目录
|
272
|
+
def open_ipa_file_path
|
273
|
+
path = final_archive_path
|
274
|
+
open_cmd = "open #{path}"
|
275
|
+
system(open_cmd)
|
276
|
+
end
|
277
|
+
|
242
278
|
end
|
243
279
|
|
244
280
|
end
|
@@ -0,0 +1,149 @@
|
|
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('pgy upload response: ')
|
111
|
+
Log.info(json_value)
|
112
|
+
# 成功
|
113
|
+
data = json_value["data"]
|
114
|
+
short_url = data["buildShortcutUrl"]
|
115
|
+
qr_code_url = data["buildQRCodeURL"]
|
116
|
+
@short_url = short_url
|
117
|
+
@qr_code_url = qr_code_url
|
118
|
+
Log.error(@short_url)
|
119
|
+
Log.error(@qr_code_url)
|
120
|
+
else
|
121
|
+
# 失败
|
122
|
+
Log.error("pgy publish fail, please check !!!")
|
123
|
+
exit(1)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
# 获取下载链接
|
129
|
+
def get_download_url
|
130
|
+
# 需要有固定的前缀
|
131
|
+
url = "https://www.pgyer.com/" + @short_url
|
132
|
+
|
133
|
+
Log.divider
|
134
|
+
Log.info(url)
|
135
|
+
|
136
|
+
url
|
137
|
+
end
|
138
|
+
|
139
|
+
# 获取二维码链接
|
140
|
+
def get_qr_code_url
|
141
|
+
url = "#{@qr_code_url}"
|
142
|
+
|
143
|
+
Log.divider
|
144
|
+
Log.info(url)
|
145
|
+
|
146
|
+
url
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
data/ocean_package.gemspec
CHANGED
@@ -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.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ocean
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-26 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
|