mirror of
https://github.com/ruby/setup-ruby.git
synced 2026-09-13 22:44:20 +02:00
58 lines
1.3 KiB
Ruby
58 lines
1.3 KiB
Ruby
engine_input, version = ARGV.fetch(0).split('-', 2)
|
|
|
|
MATCH = case engine_input
|
|
when 'ruby', 'jruby'
|
|
/^\d+\.\d+\./
|
|
when 'truffleruby'
|
|
/^\d+\./
|
|
end
|
|
|
|
raise unless version[MATCH]
|
|
|
|
engines = [engine_input]
|
|
engines << 'truffleruby+graalvm' if engine_input == 'truffleruby'
|
|
|
|
engines.each do |engine|
|
|
puts engine
|
|
|
|
# Update ruby-builder-versions.json
|
|
file = "#{__dir__}/ruby-builder-versions.json"
|
|
lines = File.readlines(file, chomp: true)
|
|
|
|
from = lines.index { |line| line.include?(%{"#{engine}": [}) }
|
|
raise "Could not find start of #{engine}" unless from
|
|
to = from
|
|
to += 1 until lines[to].include?(']')
|
|
|
|
from += 1 # [
|
|
to -= 2 # head, ]
|
|
|
|
puts lines[from..to]
|
|
|
|
release_line = lines[from..to].find { |line|
|
|
v = line[/"([^"]+)"/, 1] and v[MATCH] == version[MATCH]
|
|
}
|
|
|
|
if release_line
|
|
append = " #{version.inspect},"
|
|
release_line << append unless release_line.end_with?(append)
|
|
else
|
|
lines.insert to+1, " #{version.inspect},"
|
|
end
|
|
|
|
File.write(file, lines.join("\n") + "\n")
|
|
|
|
# Update README.md
|
|
file = "#{__dir__}/README.md"
|
|
lines = File.readlines(file)
|
|
engine_line = lines.find { |line| line.start_with?("| `#{engine}`") }
|
|
engine_line.sub!(/(.+ (?:-|until)) (\d+(?:\.\d+)+)/) do
|
|
if Gem::Version.new(version) > Gem::Version.new($2)
|
|
"#{$1} #{version}"
|
|
else
|
|
$&
|
|
end
|
|
end
|
|
File.write(file, lines.join)
|
|
end
|