forked from tomvanbraeckel/yamcs.github.com
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate-release-info.rb
More file actions
executable file
·70 lines (58 loc) · 2.22 KB
/
update-release-info.rb
File metadata and controls
executable file
·70 lines (58 loc) · 2.22 KB
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
65
66
67
68
69
70
require 'bundler/setup'
require 'octokit'
require 'json'
def pull_repo_info(client, repo)
releases_by_target = {}
for r in client.releases "yamcs/#{repo}" do
next if r.prerelease or r.draft
release = {
'name': r.name,
'tag_name': r.tag_name,
'version': r.tag_name.gsub(/[^0-9.]+/, ''),
'created_at': r.created_at,
'published_at': r.published_at,
'body': r.body,
}
target = 'master'
if repo == 'yamcs' then
if release[:version].start_with? '4.' then
target = 'master'
elsif release[:version].start_with? '3.' then
target = 'legacy'
else
next
end
end
if repo == 'yamcs-studio' and release[:version].start_with? '1.0.' then
target = 'legacy'
end
if not releases_by_target[target] then
releases_by_target[target] = []
end
for a in r.assets do
asset = {'name': a.name, 'size': a.size, 'url': a.browser_download_url}
if repo == 'yamcs' then
if not a.name.include? 'simulation' and not a.name.include? 'client' then
release[:tgz] = asset if a.name.end_with? '.tar.gz'
release[:rpm] = asset if a.name.end_with? '.rpm'
end
elsif repo == 'yamcs-studio' then
release[:windows] = asset if a.name.include? 'win32'
release[:macos] = asset if a.name.include? 'cocoa'
release[:linux] = asset if a.name.include? 'linux'
end
end
releases_by_target[target].push(release)
end
Dir.mkdir("_data/releases/#{repo}") unless File.directory?("_data/releases/#{repo}")
for target, releases in releases_by_target do
File.open("_data/releases/#{repo}/#{target}.json", 'w') do |f|
f.write(JSON.pretty_generate(releases))
end
end
end
# Login to avoid rate limit exceptions when running from Travis
client = Octokit::Client.new(:access_token => ENV['GITHUB_TOKEN'])
client.auto_paginate = true
pull_repo_info client, 'yamcs'
pull_repo_info client, 'yamcs-studio'