@@ -16,7 +16,7 @@ const execFile = Util.promisify(ChildProcess.execFile);
16
16
async function run ( ) {
17
17
try {
18
18
const params = {
19
- "crystal" : getPlatform ( ) === Windows ? "nightly" : "latest" ,
19
+ "crystal" : "latest" ,
20
20
"shards" : "true" ,
21
21
} ;
22
22
for ( const key of [ "crystal" , "shards" , "arch" ] ) {
@@ -86,9 +86,11 @@ const Any = "true";
86
86
const None = "false" ;
87
87
const NumericVersion = / ^ \d ( [ . \d ] * \d ) ? $ / ;
88
88
89
- function checkVersion ( version , allowed ) {
89
+ function checkVersion ( version , allowed , earliestAllowed = null ) {
90
90
const numericVersion = NumericVersion . test ( version ) && version ;
91
- allowed [ allowed . indexOf ( NumericVersion ) ] = numericVersion ;
91
+ if ( numericVersion && ( ! earliestAllowed || cmpTags ( numericVersion , earliestAllowed ) >= 0 ) ) {
92
+ allowed [ allowed . indexOf ( NumericVersion ) ] = numericVersion ;
93
+ }
92
94
93
95
if ( allowed . includes ( version ) ) {
94
96
return version ;
@@ -334,7 +336,8 @@ async function downloadCrystalRelease(filePattern, version = null) {
334
336
335
337
const downloadedPath = await ToolCache . downloadTool ( url ) ;
336
338
Core . info ( "Extracting Crystal build" ) ;
337
- const extractedPath = await ToolCache . extractTar ( downloadedPath ) ;
339
+ const dl = ( asset [ "name" ] . endsWith ( ".zip" ) ? ToolCache . extractZip : ToolCache . extractTar ) ;
340
+ const extractedPath = await dl ( downloadedPath ) ;
338
341
return onlySubdir ( extractedPath ) ;
339
342
}
340
343
@@ -397,9 +400,15 @@ async function downloadCrystalNightly(filePattern) {
397
400
}
398
401
399
402
async function installCrystalForWindows ( { crystal, shards, arch = "x86_64" , path} ) {
400
- checkVersion ( crystal , [ Nightly ] ) ;
403
+ checkVersion ( crystal , [ Latest , Nightly , NumericVersion ] , "1.3" ) ;
401
404
checkArch ( arch , [ "x86_64" ] ) ;
402
- await IO . mv ( await downloadCrystalNightlyForWindows ( ) , path ) ;
405
+
406
+ if ( crystal === Nightly ) {
407
+ await IO . mv ( await downloadCrystalNightlyForWindows ( ) , path ) ;
408
+ } else {
409
+ const filePattern = / - w i n d o w s - x 8 6 _ 6 4 - m s v c ( - u n s u p p o r t e d ) ? \. z i p $ / ;
410
+ await installBinaryRelease ( { crystal, shards, filePattern, path} ) ;
411
+ }
403
412
404
413
Core . info ( "Setting up environment for Crystal" ) ;
405
414
Core . addPath ( path ) ;
@@ -450,8 +459,11 @@ async function* getItemsFromPages(pages) {
450
459
}
451
460
452
461
async function onlySubdir ( path ) {
453
- const [ subDir ] = await FS . readdir ( path ) ;
454
- return Path . join ( path , subDir ) ;
462
+ const subDirs = await FS . readdir ( path ) ;
463
+ if ( subDirs . length === 1 ) {
464
+ path = Path . join ( path , subDirs [ 0 ] ) ;
465
+ }
466
+ return path ;
455
467
}
456
468
457
469
if ( require . main === module ) {
0 commit comments