update script - todo error handling

This commit is contained in:
Jiting 2019-03-25 16:45:51 +08:00
parent 18d1af92d9
commit d1cbff9004
No known key found for this signature in database
GPG Key ID: B68ED772995769D6
2 changed files with 15 additions and 15 deletions

View File

@ -1,13 +0,0 @@
GEM
remote: https://rubygems.org/
specs:
rubyzip (1.2.2)
PLATFORMS
x64-mingw32
DEPENDENCIES
rubyzip
BUNDLED WITH
1.17.2

View File

@ -1,6 +1,7 @@
#!/usr/bin/env ruby
require "zip"
require 'net/http'
require "open3"
Zip.setup do |c|
@ -65,8 +66,20 @@ end
def send_progress(done, total)
percentage = Rational(done*100,total).round(2).to_f
puts "当前进度:\n#{done}/#{total}", percentage
# TODO: push to telegram
info = "当前进度:\n#{done}/#{total}\n#{percentage}%\n".freeze
puts info
telegram_push(info)
end
def telegram_push(string)
tg_api = ENV['TG_API']
group_id = ENV['TG_GROUP_ID']
uri = URI("https://api.telegram.org/bot#{tg_api}/sendMessage")
querystring = {chat_id: group_id ,text: string}
uri.query = URI.encode_www_form(querystring)
res = Net::HTTP.get_response(uri)
puts res.code
# TODO: error handling
end
def make_package(zipfile_name, build_version=nil, log_url=nil)