generated from actions/javascript-action
-
-
Notifications
You must be signed in to change notification settings - Fork 263
/
generate-windows-versions.rb
33 lines (28 loc) · 1.38 KB
/
generate-windows-versions.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
require 'net/http'
require 'yaml'
require 'json'
min_requirements = ['~> 2.0.0', '~> 2.1.9', '>= 2.2.6'].map { |req| Gem::Requirement.new(req) }
url = 'https://raw.githubusercontent.com/oneclick/rubyinstaller.org-website/master/_data/downloads.yaml'
entries = YAML.load(Net::HTTP.get(URI(url)), symbolize_names: true)
versions = entries.select { |entry|
entry[:filetype] == 'rubyinstaller7z' and
entry[:name].include?('(x64)')
}.group_by { |entry|
entry[:name][/Ruby (\d+\.\d+\.\d+)/, 1]
}.map { |version, builds|
unless builds.sort_by { |build| build[:name] } == builds.reverse
raise "not sorted as expected for #{version}"
end
[version, builds.first]
}.sort_by { |version, entry|
Gem::Version.new(version)
}.select { |version, entry|
min_requirements.any? { |req| req.satisfied_by?(Gem::Version.new(version)) }
}.map { |version, entry|
[version, entry[:href]]
}.to_h
versions['head'] = 'https://github.com/oneclick/rubyinstaller2/releases/download/rubyinstaller-head/rubyinstaller-head-x64.7z'
versions['mingw'] = 'https://github.com/MSP-Greg/ruby-loco/releases/download/ruby-master/ruby-mingw.7z'
versions['mswin'] = 'https://github.com/MSP-Greg/ruby-loco/releases/download/ruby-master/ruby-mswin.7z'
versions['ucrt'] = 'https://github.com/MSP-Greg/ruby-loco/releases/download/ruby-master/ruby-ucrt.7z'
File.binwrite 'windows-versions.json', "#{JSON.pretty_generate(versions)}\n"