Skip to content

Commit 3065f0b

Browse files
committed
Add script to automatically add a version to ruby-builder-versions.json
1 parent cf617ba commit 3065f0b

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

new-version.rb

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
engine, version = ARGV.fetch(0).split('-', 2)
2+
3+
MATCH = case engine
4+
when 'ruby', 'jruby'
5+
/^\d+\.\d+\./
6+
when 'truffleruby'
7+
/^\d+\./
8+
end
9+
10+
raise unless version[MATCH]
11+
12+
file = "#{__dir__}/ruby-builder-versions.json"
13+
lines = File.readlines(file, chomp: true)
14+
15+
from = lines.index { |line| line =~ /"#{engine}": \[/ }
16+
to = from
17+
to += 1 until lines[to].include?(']')
18+
19+
from += 1 # [
20+
to -= 2 # head, ]
21+
22+
puts lines[from..to]
23+
24+
release_line = lines[from..to].find { |line|
25+
v = line[/"([^"]+)"/, 1] and v[MATCH] == version[MATCH]
26+
}
27+
28+
if release_line
29+
release_line << " #{version.inspect},"
30+
else
31+
lines.insert to+1, " #{version.inspect},"
32+
end
33+
34+
File.write(file, lines.join("\n") + "\n")

0 commit comments

Comments
 (0)