Skip to content

Commit a3be174

Browse files
committed
Use swiftly for linux and disable mac and windows
1 parent 9137113 commit a3be174

File tree

1 file changed

+24
-25
lines changed

1 file changed

+24
-25
lines changed

src/main.ts

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,35 @@
11
import { EOL } from "os";
2-
import * as core from "@actions/core";
3-
import * as system from "./os";
4-
import * as versions from "./swift-versions";
5-
import * as macos from "./macos-install";
6-
import * as linux from "./linux-install";
7-
import * as windows from "./windows-install";
8-
import { getVersion } from "./get-version";
2+
import { getOS } from "./core";
3+
import { installSwift, setupLinux } from "./swiftly";
4+
import { currentVersion } from "./swift";
5+
import { error, getInput, setFailed, setOutput } from "@actions/core";
96

7+
/**
8+
* Main entry point for the action
9+
*/
1010
async function run() {
1111
try {
12-
const requestedVersion = core.getInput("swift-version", { required: true });
12+
const version = getInput("swift-version", { required: true });
13+
const os = await getOS();
1314

14-
let platform = await system.getSystem();
15-
let version = versions.verify(requestedVersion, platform);
16-
17-
switch (platform.os) {
18-
case system.OS.MacOS:
19-
await macos.install(version, platform);
20-
break;
21-
case system.OS.Ubuntu:
22-
await linux.install(version, platform);
15+
switch (os) {
16+
case "darwin":
17+
throw Error("Not implemented yet on macOS");
18+
case "linux":
19+
await setupLinux();
2320
break;
24-
case system.OS.Windows:
25-
await windows.install(version, platform);
21+
case "win32":
22+
throw Error("Not implemented yet on Windows");
2623
}
2724

28-
const current = await getVersion();
25+
await installSwift(version);
26+
27+
const current = await currentVersion();
2928
if (current === version) {
30-
core.setOutput("version", version);
29+
setOutput("version", version);
3130
} else {
32-
core.error(
33-
`Failed to setup requested swift version. requestd: ${version}, actual: ${current}`
31+
error(
32+
`Failed to setup requested swift version. requestd: ${version}, actual: ${current}`,
3433
);
3534
}
3635
} catch (error) {
@@ -41,8 +40,8 @@ async function run() {
4140
dump = `${error}`;
4241
}
4342

44-
core.setFailed(
45-
`Unexpected error, unable to continue. Please report at https://github.com/swift-actions/setup-swift/issues${EOL}${dump}`
43+
setFailed(
44+
`Unexpected error, unable to continue. Please report at https://github.com/swift-actions/setup-swift/issues${EOL}${dump}`,
4645
);
4746
}
4847
}

0 commit comments

Comments
 (0)