@@ -113,13 +113,13 @@ async function subprocess(command, options) {
113
113
114
114
async function installCrystalForLinux ( { crystal, shards, arch = getArch ( ) , path} ) {
115
115
checkVersion ( crystal , [ Latest , Nightly , NumericVersion ] ) ;
116
- const suffixes = { "x86_64" : " linux-x86_64" , "x86" : " linux-i686" } ;
117
- checkArch ( arch , Object . keys ( suffixes ) ) ;
116
+ const filePatterns = { "x86_64" : / - l i n u x - x 8 6 _ 6 4 \. t a r \. g z $ / , "x86" : / - l i n u x - i 6 8 6 \. t a r \. g z $ / } ;
117
+ checkArch ( arch , Object . keys ( filePatterns ) ) ;
118
118
119
119
const depsTask = installAptPackages (
120
120
"libevent-dev libgmp-dev libpcre3-dev libssl-dev libxml2-dev libyaml-dev" . split ( " " ) ,
121
121
) ;
122
- await installBinaryRelease ( { crystal, shards, suffix : suffixes [ arch ] , path} ) ;
122
+ await installBinaryRelease ( { crystal, shards, filePattern : filePatterns [ arch ] , path} ) ;
123
123
124
124
Core . info ( "Setting up environment for Crystal" ) ;
125
125
Core . addPath ( Path . join ( path , "bin" ) ) ;
@@ -136,11 +136,11 @@ async function installCrystalForMac({crystal, shards, arch = "x86_64", path}) {
136
136
checkVersion ( crystal , [ Latest , Nightly , NumericVersion ] ) ;
137
137
if ( crystal === Latest || crystal === Nightly || cmpTags ( crystal , "1.2" ) >= 0 ) {
138
138
checkArch ( arch , [ "universal" , "x86_64" , "aarch64" ] ) ;
139
- await installBinaryRelease ( { crystal, shards, suffix : "darwin-universal" , path} ) ;
140
139
} else {
141
140
checkArch ( arch , [ "x86_64" ] ) ;
142
- await installBinaryRelease ( { crystal, shards, suffix : "darwin-x86_64" , path} ) ;
143
141
}
142
+ const filePattern = / - d a r w i n - ( u n i v e r s a l | x 8 6 _ 6 4 ) \. t a r \. g z $ / ;
143
+ await installBinaryRelease ( { crystal, shards, filePattern, path} ) ;
144
144
145
145
Core . info ( "Setting up environment for Crystal" ) ;
146
146
Core . addPath ( Path . join ( path , "embedded" , "bin" ) ) ;
@@ -176,14 +176,14 @@ async function installAptPackages(packages) {
176
176
Core . endGroup ( ) ;
177
177
}
178
178
179
- async function installBinaryRelease ( { crystal, suffix , path} ) {
179
+ async function installBinaryRelease ( { crystal, filePattern , path} ) {
180
180
if ( crystal === Nightly ) {
181
- await IO . mv ( await downloadCrystalNightly ( suffix ) , path ) ;
181
+ await IO . mv ( await downloadCrystalNightly ( filePattern ) , path ) ;
182
182
} else {
183
183
if ( crystal === Latest ) {
184
184
crystal = null ;
185
185
}
186
- await IO . mv ( await downloadCrystalRelease ( suffix , crystal ) , path ) ;
186
+ await IO . mv ( await downloadCrystalRelease ( filePattern , crystal ) , path ) ;
187
187
}
188
188
}
189
189
@@ -318,11 +318,11 @@ async function findLatestCommit({name, repo, branch = "master"}) {
318
318
return commit [ "sha" ] ;
319
319
}
320
320
321
- async function downloadCrystalRelease ( suffix , version = null ) {
321
+ async function downloadCrystalRelease ( filePattern , version = null ) {
322
322
const release = await findRelease ( { name : "Crystal" , repo : RepoCrystal , tag : version } ) ;
323
323
Core . setOutput ( "crystal" , release [ "tag_name" ] ) ;
324
324
325
- const asset = release [ "assets" ] . find ( ( a ) => a [ "name" ] . endsWith ( [ `- ${ suffix } .tar.gz` ] ) ) ;
325
+ const asset = release [ "assets" ] . find ( ( a ) => filePattern . test ( a [ "name" ] ) ) ;
326
326
327
327
Core . info ( `Downloading Crystal build from ${ asset [ "url" ] } ` ) ;
328
328
const resp = await github . request ( {
@@ -364,7 +364,7 @@ async function downloadSource({name, repo, ref}) {
364
364
return onlySubdir ( await ToolCache . extractZip ( downloadedPath ) ) ;
365
365
}
366
366
367
- async function downloadCrystalNightly ( suffix ) {
367
+ async function downloadCrystalNightly ( filePattern ) {
368
368
Core . info ( "Looking for latest Crystal build" ) ;
369
369
370
370
let build ;
@@ -387,7 +387,7 @@ async function downloadCrystalNightly(suffix) {
387
387
const req = `/${ build [ "build_num" ] } /artifacts` ;
388
388
const resp = await fetch ( CircleApiBase + req ) ;
389
389
const artifacts = await resp . json ( ) ;
390
- const artifact = artifacts . find ( ( a ) => a [ "path" ] . endsWith ( `- ${ suffix } .tar.gz` ) ) ;
390
+ const artifact = artifacts . find ( ( a ) => filePattern . test ( a [ "path" ] ) ) ;
391
391
392
392
Core . info ( `Downloading Crystal build from ${ artifact [ "url" ] } ` ) ;
393
393
const downloadedPath = await ToolCache . downloadTool ( artifact [ "url" ] ) ;
0 commit comments