Skip to content

Commit ba6cb3f

Browse files
committed
Create installer without using swiftly
1 parent 21bb733 commit ba6cb3f

File tree

5 files changed

+34
-43
lines changed

5 files changed

+34
-43
lines changed

src/main.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { EOL } from "os";
22
import { equalVersions, getOS } from "./core";
3-
import { installSwift, setupLinux, setupMacOS, setupWindows } from "./swiftly";
4-
import { currentVersion } from "./swift";
3+
import { installSwift, setupLinux, setupMacOS } from "./swiftly";
4+
import { currentVersion, setupWindows } from "./swift";
55
import { error, getInput, info, setFailed, setOutput } from "@actions/core";
66

77
/**
@@ -24,18 +24,17 @@ async function run() {
2424
switch (os) {
2525
case "darwin":
2626
await setupMacOS();
27+
await installSwift(version);
2728
break;
2829
case "linux":
2930
await setupLinux({ skipVerifySignature: true });
31+
await installSwift(version);
3032
break;
3133
case "win32":
32-
await setupWindows();
34+
await setupWindows(version);
3335
break;
3436
}
3537

36-
// Install the requested version
37-
await installSwift(version);
38-
3938
// Verify the requested version is now installed
4039
current = await currentVersion();
4140
if (equalVersions(version, current)) {

src/swift/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export * from "./current-version";
2+
export * from "./windows";

src/swift/windows.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { addPath, debug } from "@actions/core";
2+
import { downloadTool, find } from "@actions/tool-cache";
3+
import { cmd } from "../core";
4+
import { machine } from "os";
5+
6+
/**
7+
* Setup Swift on Windows as theres no support for Swiftly yet.
8+
*/
9+
export async function setupWindows(version: string) {
10+
await download(version);
11+
}
12+
13+
async function download(version: string) {
14+
const m = machine();
15+
16+
let url: string;
17+
if (m === "arm64") {
18+
url = `https://download.swift.org/swift-${version}-release/windows10-arm64/swift-${version}-RELEASE/swift-${version}-RELEASE-windows10-arm64.exe`;
19+
} else {
20+
url = `https://download.swift.org/swift-${version}-release/windows10/swift-${version}-RELEASE/swift-${version}-RELEASE-windows10.exe`;
21+
}
22+
23+
debug(`Downloading Swift installer from ${url}`);
24+
25+
const installerPath = await downloadTool(url);
26+
27+
await cmd(installerPath);
28+
}

src/swiftly/installers/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
export * from "./linux";
22
export * from "./macos";
3-
export * from "./windows";

src/swiftly/installers/windows.ts

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)