forked from ruby/ruby-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rb
35 lines (28 loc) · 1.04 KB
/
build.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
34
35
def sh(*command)
puts command.join(' ')
raise "#{command} failed" unless system(*command)
end
versions = ARGV.dup
versions.dup.each do |engine_version|
engine, version = engine_version.split('-', 2)
if engine == 'truffleruby'
versions << "truffleruby+graalvm-#{version}"
end
end
jruby = versions.any? { |v| v.start_with?('jruby-') }
file = ".github/workflows/build.yml"
lines = File.readlines(file)
unix = lines.find { |line| line.include?('ruby: ') }
windows = lines.find { |line| line.include?('jruby-version: ') }
raise unless unix && windows
unix.sub!(/ruby: .+/, "ruby: [#{versions.join(', ')}]")
if jruby
windows.sub!(/jruby-version: .+/, "jruby-version: [#{versions.map { |v| v.delete_prefix('jruby-') }.join(', ')}]")
end
if_lines = lines.select { |line| line.match?(/^ if: (true|false)/) }
raise unless if_lines.size == 2
if_lines[0].sub!(/if: (true|false)/, 'if: true')
if_lines[1].sub!(/if: (true|false)/, "if: #{jruby}")
File.write(file, lines.join)
sh 'git', 'add', file
sh 'git', 'commit', '-m', "Build #{versions.join(',')}"