Skip to content

Commit 22e3837

Browse files
committed
Add script to copy each asset to a engine-version release
1 parent 4812089 commit 22e3837

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

copy_to_separate_releases.rb

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
require 'json'
2+
3+
def sh(*args, **kwargs)
4+
puts "$ #{args.join(' ')}"
5+
system(*args, exception: true, **kwargs)
6+
end
7+
8+
assets = JSON.load(`gh release view toolcache --json assets`).fetch('assets')
9+
10+
filter = ARGV[0] || 'jruby-10.0.0.0'
11+
12+
PLATFORM_MAPPING = {
13+
'macos-latest' => 'darwin-x64',
14+
'macos-13-arm64' => 'darwin-arm64',
15+
'ubuntu-22.04' => 'ubuntu-22.04-x64',
16+
'ubuntu-22.04-arm64' => 'ubuntu-22.04-arm64',
17+
'ubuntu-24.04' => 'ubuntu-24.04-x64',
18+
'ubuntu-24.04-arm64' => 'ubuntu-24.04-arm64',
19+
'windows-latest' => 'windows-x64',
20+
'windows-arm64' => 'windows-arm64',
21+
}
22+
23+
assets.each do |asset|
24+
name = asset['name']
25+
raise name unless /^(?<engine>[\w+]+)-(?<version>[\d.]+(?:-(p|preview|rc)\d+)?)-(?<platform>\w+-.+)\.tar\.gz$/ =~ name
26+
new_platform = PLATFORM_MAPPING.fetch(platform)
27+
new_name = "#{engine}-#{version}-#{new_platform}.tar.gz"
28+
if name.start_with?(filter)
29+
puts name
30+
tag = "#{engine}-#{version}"
31+
notes = "Builds of #{tag}"
32+
33+
unless sh 'gh', 'release', 'view', tag, out: File::NULL, exception: false
34+
sh 'gh', 'release', 'create', tag, '--notes', notes
35+
end
36+
37+
sh 'gh', 'release', 'download', 'toolcache', '--pattern', name
38+
File.rename name, new_name
39+
sh 'gh', 'release', 'upload', tag, new_name
40+
File.delete new_name
41+
end
42+
end

0 commit comments

Comments
 (0)