forked from hivewallet/hive-mac
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate_appcast_code.rb
executable file
·64 lines (52 loc) · 1.75 KB
/
generate_appcast_code.rb
1
2
3
4
5
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
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env ruby
require 'json'
require 'open-uri'
require 'time'
if ARGV.length < 4
puts "Usage: #{$PROGRAM_NAME} <version> <build> <local_zip_file> <private_key_file>"
exit 1
end
version, build, local_zip_file, private_key_file = ARGV
local_zip_file = File.expand_path(local_zip_file)
file_size = File.size(local_zip_file)
signature = %x(./sign_update.rb #{local_zip_file} #{private_key_file}).gsub(/\s+/, '')
json = JSON.parse(open("https://api.github.com/repos/hivewallet/hive-osx/releases").read)
release = json.detect { |r| r['tag_name'] == version }
unless release
puts "Error: Release #{version} not found on GitHub."
exit 1
end
date = Time.parse(release['published_at']).rfc822
release_notes = release['body'].gsub(/\- (.*?)\r\n/, " <li>\\1</li>\n").strip
zip_asset = release['assets'].detect { |a| a['content_type'] == 'application/zip' }
unless zip_asset
puts "Error: Release #{version} has no zip file uploaded."
exit 1
end
zip_url = "https://github.com/hivewallet/hive-osx/releases/download/#{version}/#{zip_asset['name']}"
puts %(
<item>
<title>Hive #{version}</title>
<description>
<![CDATA[
<style type="text/css">
h2 { font-family: Helvetica; font-weight: bold; font-size: 10pt; }
ul { font-family: Helvetica; font-size: 10pt; }
li { margin: 5px 0px; }
</style>
<h2>What's changed:</h2>
<ul>
#{release_notes}
</ul>
]]>
</description>
<pubDate>#{date}</pubDate>
<enclosure
url="#{zip_url}"
sparkle:version="#{build}"
sparkle:shortVersionString="#{version}"
length="#{file_size}"
type="application/octet-stream"
sparkle:dsaSignature="#{signature}" />
</item>
)