Skip to content

Commit d109bcf

Browse files
committed
Support installing tagged versions of Crystal on Windows
1 parent ad0fe57 commit d109bcf

File tree

4 files changed

+25
-21
lines changed

4 files changed

+25
-21
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,12 @@ jobs:
2020
- {shards: false}
2121
- {shards: true}
2222
- {shards: '0.12.0', crystal: '0.35.1'}
23-
- {shards: '0.14', crystal: '1.2'}
23+
- {shards: '0.14', crystal: '1.3'}
2424
- {shards: latest, crystal: latest}
2525
- {shards: nightly, crystal: nightly}
2626
exclude:
2727
- os: windows-latest
2828
config: {shards: '0.12.0', crystal: '0.35.1'}
29-
- os: windows-latest
30-
config: {shards: '0.14', crystal: '1.2'}
31-
- os: windows-latest
32-
config: {shards: latest, crystal: latest}
3329

3430
name: crystal ${{ matrix.config.crystal }} + shards ${{ matrix.config.shards }} (${{ matrix.os }})
3531
runs-on: ${{ matrix.os }}

.github/workflows/release.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,12 @@ jobs:
2020
- {shards: false}
2121
- {shards: true}
2222
- {shards: '0.12.0', crystal: '0.35.1'}
23-
- {shards: '0.14', crystal: '1.2'}
23+
- {shards: '0.14', crystal: '1.3'}
2424
- {shards: latest, crystal: latest}
2525
- {shards: nightly, crystal: nightly}
2626
exclude:
2727
- os: windows-latest
2828
config: {shards: '0.12.0', crystal: '0.35.1'}
29-
- os: windows-latest
30-
config: {shards: '0.14', crystal: '1.2'}
31-
- os: windows-latest
32-
config: {shards: latest, crystal: latest}
3329

3430
name: crystal ${{ matrix.config.crystal }} + shards ${{ matrix.config.shards }} (${{ matrix.os }})
3531
runs-on: ${{ matrix.os }}

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,15 @@ Alternatively, you can use the container-based approach [as in the starter workf
5656
5757
### Inputs
5858
59-
* * **`crystal: 1.1.0`**, **`crystal: 1.2`** (not supported on Windows)
59+
* * **`crystal: 1.1.0`**, **`crystal: 1.2`**
6060

6161
Install a particular release of Crystal (if the full version is specified), or the latest patch version of a release series.
6262

63-
* **`crystal: latest`** (default; not supported on Windows)
63+
* **`crystal: latest`** (default)
6464

6565
Install the latest released version of Crystal.
6666

67-
* **`crystal: nightly`** (default on Windows)
67+
* **`crystal: nightly`**
6868

6969
Install Crystal from the latest continuous build on [crystal.git][] master.
7070

index.js

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const execFile = Util.promisify(ChildProcess.execFile);
1616
async function run() {
1717
try {
1818
const params = {
19-
"crystal": getPlatform() === Windows ? "nightly" : "latest",
19+
"crystal": "latest",
2020
"shards": "true",
2121
};
2222
for (const key of ["crystal", "shards", "arch"]) {
@@ -86,9 +86,11 @@ const Any = "true";
8686
const None = "false";
8787
const NumericVersion = /^\d([.\d]*\d)?$/;
8888

89-
function checkVersion(version, allowed) {
89+
function checkVersion(version, allowed, earliestAllowed = null) {
9090
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+
}
9294

9395
if (allowed.includes(version)) {
9496
return version;
@@ -334,7 +336,8 @@ async function downloadCrystalRelease(filePattern, version = null) {
334336

335337
const downloadedPath = await ToolCache.downloadTool(url);
336338
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);
338341
return onlySubdir(extractedPath);
339342
}
340343

@@ -397,9 +400,15 @@ async function downloadCrystalNightly(filePattern) {
397400
}
398401

399402
async function installCrystalForWindows({crystal, shards, arch = "x86_64", path}) {
400-
checkVersion(crystal, [Nightly]);
403+
checkVersion(crystal, [Latest, Nightly, NumericVersion], "1.3");
401404
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 = /-windows-x86_64-msvc(-unsupported)?\.zip$/;
410+
await installBinaryRelease({crystal, shards, filePattern, path});
411+
}
403412

404413
Core.info("Setting up environment for Crystal");
405414
Core.addPath(path);
@@ -450,8 +459,11 @@ async function* getItemsFromPages(pages) {
450459
}
451460

452461
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;
455467
}
456468

457469
if (require.main === module) {

0 commit comments

Comments
 (0)