6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
|
# File 'lib/fir/util/publish.rb', line 6
def publish *args, options
file_path = File.absolute_path(args.first.to_s)
token = options[:token] || current_token
changelog = options[:changelog].to_s
check_supported_file file_path
check_token_cannot_be_blank token
fetch_user_info(token)
logger.info "Publishing app......."
logger_info_dividing_line
file_type = File.extname(file_path).delete(".")
@app_info = send("#{file_type}_info", file_path, true)
uploading_info = fetch_uploading_info(type: @app_info[:type],
bundle_id: @app_info[:identifier],
api_token: token)
app_id = uploading_info[:id]
icon_cert = uploading_info[:cert][:icon]
binary_cert = uploading_info[:cert][:binary]
unless @app_info[:icons].blank?
large_icon_path = @app_info[:icons].max_by { |f| File.size(f) }
uncrushed_icon_path = convert_icon(large_icon_path)
upload_app_icon(icon_cert, uncrushed_icon_path)
end
uploaded_info = upload_app_binary(binary_cert, file_path, changelog)
if uploaded_info[:is_completed]
unless @app_info[:devices].blank?
upload_device_info(key: binary_cert[:key],
udids: @app_info[:devices].join(","),
api_token: token)
end
unless options[:short].blank?
update_app_info(app_id, short: options[:short], api_token: token)
end
published_app_info = fetch_app_info(app_id, api_token: token)
logger_info_dividing_line
logger.info "Published succeed: #{api[:domain]}/#{published_app_info[:short]}"
end
end
|