@@ -13,16 +13,6 @@ def latest_build_sources
13
13
. to_h
14
14
end
15
15
16
- NPM_RELEASE_ARTIFACTS = %w[
17
- npm-ruby-head-wasm-emscripten
18
- npm-ruby-head-wasm-wasi
19
- npm-ruby-3_2-wasm-wasi
20
- ]
21
- RELASE_ARTIFACTS =
22
- BUILD_TASKS . map do |build |
23
- File . basename ( build . crossruby . artifact , ".tar.gz" )
24
- end + NPM_RELEASE_ARTIFACTS
25
-
26
16
def release_note
27
17
output = <<EOS
28
18
| channel | source |
@@ -52,56 +42,60 @@ def sh_or_warn(*cmd)
52
42
end
53
43
end
54
44
45
+ def rake_task_matrix
46
+ require "pathname"
47
+ ruby_cache_keys = { }
48
+ BUILD_TASKS . each { |build | ruby_cache_keys [ build . name ] = build . hexdigest }
49
+ build_entries =
50
+ BUILD_TASKS . map do |build |
51
+ {
52
+ task : "build:#{ build . name } " ,
53
+ artifact :
54
+ Pathname
55
+ . new ( build . crossruby . artifact )
56
+ . relative_path_from ( LIB_ROOT )
57
+ . to_s ,
58
+ artifact_name : File . basename ( build . crossruby . artifact , ".tar.gz" ) ,
59
+ builder : build . target ,
60
+ rubies_cache_key : ruby_cache_keys [ build . name ]
61
+ }
62
+ end
63
+ npm_entries =
64
+ NPM_PACKAGES . map do |pkg |
65
+ entry = {
66
+ task : "npm:#{ pkg [ :name ] } " ,
67
+ prerelease : "npm:configure_prerelease" ,
68
+ artifact : "packages/npm-packages/#{ pkg [ :name ] } /#{ pkg [ :name ] } -*.tgz" ,
69
+ artifact_name : "npm-#{ pkg [ :name ] } " ,
70
+ builder : pkg [ :target ] ,
71
+ rubies_cache_key : ruby_cache_keys [ pkg [ :build ] ]
72
+ }
73
+ # Run tests only if the package has 'test' script
74
+ package_json =
75
+ JSON . parse (
76
+ File . read ( "packages/npm-packages/#{ pkg [ :name ] } /package.json" )
77
+ )
78
+ if package_json [ "scripts" ] && package_json [ "scripts" ] [ "test" ]
79
+ entry [ :test ] = "npm:#{ pkg [ :name ] } -check"
80
+ end
81
+ entry
82
+ end
83
+ wapm_entries =
84
+ WAPM_PACKAGES . map do |pkg |
85
+ {
86
+ task : "wapm:#{ pkg [ :name ] } -build" ,
87
+ artifact : "packages/wapm-packages/#{ pkg [ :name ] } /dist" ,
88
+ artifact_name : "wapm-#{ pkg [ :name ] } " ,
89
+ builder : "wasm32-unknown-wasi" ,
90
+ rubies_cache_key : ruby_cache_keys [ pkg [ :build ] ]
91
+ }
92
+ end
93
+ { build : build_entries , npm : npm_entries , wapm : wapm_entries }
94
+ end
95
+
55
96
namespace :ci do
56
97
task :rake_task_matrix do
57
- require "pathname"
58
- ruby_cache_keys = { }
59
- BUILD_TASKS . each { |build | ruby_cache_keys [ build . name ] = build . hexdigest }
60
- entries =
61
- BUILD_TASKS . map do |build |
62
- {
63
- task : "build:#{ build . name } " ,
64
- artifact :
65
- Pathname
66
- . new ( build . crossruby . artifact )
67
- . relative_path_from ( LIB_ROOT )
68
- . to_s ,
69
- artifact_name : File . basename ( build . crossruby . artifact , ".tar.gz" ) ,
70
- builder : build . target ,
71
- rubies_cache_key : ruby_cache_keys [ build . name ]
72
- }
73
- end
74
- entries +=
75
- NPM_PACKAGES . map do |pkg |
76
- entry = {
77
- task : "npm:#{ pkg [ :name ] } " ,
78
- prerelease : "npm:configure_prerelease" ,
79
- artifact : "packages/npm-packages/#{ pkg [ :name ] } /#{ pkg [ :name ] } -*.tgz" ,
80
- artifact_name : "npm-#{ pkg [ :name ] } " ,
81
- builder : pkg [ :target ] ,
82
- rubies_cache_key : ruby_cache_keys [ pkg [ :build ] ]
83
- }
84
- # Run tests only if the package has 'test' script
85
- package_json =
86
- JSON . parse (
87
- File . read ( "packages/npm-packages/#{ pkg [ :name ] } /package.json" )
88
- )
89
- if package_json [ "scripts" ] && package_json [ "scripts" ] [ "test" ]
90
- entry [ :test ] = "npm:#{ pkg [ :name ] } -check"
91
- end
92
- entry
93
- end
94
- entries +=
95
- WAPM_PACKAGES . map do |pkg |
96
- {
97
- task : "wapm:#{ pkg [ :name ] } -build" ,
98
- artifact : "packages/wapm-packages/#{ pkg [ :name ] } /dist" ,
99
- artifact_name : "wapm-#{ pkg [ :name ] } " ,
100
- builder : "wasm32-unknown-wasi" ,
101
- rubies_cache_key : ruby_cache_keys [ pkg [ :build ] ]
102
- }
103
- end
104
- print JSON . generate ( entries )
98
+ print JSON . generate ( rake_task_matrix . flat_map { |_ , entries | entries } )
105
99
end
106
100
107
101
task :pin_build_manifest do
@@ -112,13 +106,15 @@ namespace :ci do
112
106
desc "Fetch artifacts of a run of GitHub Actions"
113
107
task :fetch_artifacts , [ :run_id ] do |t , args |
114
108
RubyWasm ::Toolchain . check_executable ( "gh" )
115
-
109
+
116
110
artifacts =
117
111
JSON . load (
118
112
`gh api repos/{owner}/{repo}/actions/runs/#{ args [ :run_id ] } /artifacts`
119
113
)
114
+ matrix = rake_task_matrix . flat_map { |_ , entries | entries }
115
+ release_artifacts = matrix . map { |entry | entry [ :artifact_name ] }
120
116
artifacts =
121
- artifacts [ "artifacts" ] . filter { RELASE_ARTIFACTS . include? ( _1 [ "name" ] ) }
117
+ artifacts [ "artifacts" ] . filter { release_artifacts . include? ( _1 [ "name" ] ) }
122
118
mkdir_p "release"
123
119
Dir . chdir ( "release" ) do
124
120
artifacts . each do |artifact |
@@ -130,16 +126,17 @@ namespace :ci do
130
126
end
131
127
end
132
128
end
133
-
129
+
134
130
desc "Publish artifacts as a GitHub Release"
135
131
task :publish , [ :tag ] do |t , args |
136
132
RubyWasm ::Toolchain . check_executable ( "gh" )
137
-
133
+
138
134
nightly = /^\d {4}-\d {2}-\d {2}-.$/ . match? ( args [ :tag ] )
139
- files =
140
- RELASE_ARTIFACTS . flat_map { |artifact | Dir . glob ( "release/#{ artifact } /*" ) }
135
+ matrix = rake_task_matrix
136
+ files = matrix . map { |entry | "release/#{ entry [ :artifact_name ] } /*" }
141
137
File . open ( "release/note.md" , "w" ) { |f | f . print release_note }
142
- NPM_RELEASE_ARTIFACTS . each do |artifact |
138
+ matrix [ :npm ] . each do |task |
139
+ artifact = task [ :artifact_name ]
143
140
tarball = Dir . glob ( "release/#{ artifact } /*" )
144
141
next if tarball . empty?
145
142
tarball = tarball [ 0 ]
0 commit comments