Automatically update the latest version in the README

This commit is contained in:
Benoit Daloze
2022-01-23 17:33:38 +01:00
parent f302e4ff49
commit 32c0569c64
2 changed files with 17 additions and 2 deletions
+1 -1
View File
@@ -15,7 +15,7 @@ This action currently supports these versions of MRI, JRuby and TruffleRuby:
| Interpreter | Versions |
| ----------- | -------- |
| `ruby` | 1.9.3, 2.0.0, 2.1.9, 2.2, all versions from 2.3.0 until 3.1.0, head, debug, mingw, mswin |
| `jruby` | 9.1.17.0 - 9.3.2.0, head |
| `jruby` | 9.1.17.0 - 9.3.3.0, head |
| `truffleruby` | 19.3.0 - 21.3.0, head |
| `truffleruby+graalvm` | 21.2.0 - 21.3.0, head |
+16 -1
View File
@@ -9,6 +9,7 @@ end
raise unless version[MATCH]
# Update ruby-builder-versions.json
file = "#{__dir__}/ruby-builder-versions.json"
lines = File.readlines(file, chomp: true)
@@ -26,9 +27,23 @@ release_line = lines[from..to].find { |line|
}
if release_line
release_line << " #{version.inspect},"
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)