Skip to content

Commit c671190

Browse files
committed
Check if requested version is already installed
1 parent 07dc236 commit c671190

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/main.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { EOL } from "os";
22
import { equalVersions, getOS } from "./core";
33
import { installSwift, setupLinux } from "./swiftly";
44
import { currentVersion } from "./swift";
5-
import { error, getInput, setFailed, setOutput } from "@actions/core";
5+
import { error, getInput, info, setFailed, setOutput } from "@actions/core";
66
import { coerce, eq } from "semver";
77

88
/**
@@ -13,6 +13,14 @@ async function run() {
1313
const version = getInput("swift-version", { required: true });
1414
const os = await getOS();
1515

16+
// First check if the requested version is already installed
17+
let current = await currentVersion().catch(() => null);
18+
if (equalVersions(version, current)) {
19+
info(`Swift ${version} is already installed`);
20+
setOutput("version", version);
21+
return;
22+
}
23+
1624
// Setup Swiftly on the runner
1725
switch (os) {
1826
case "darwin":

0 commit comments

Comments
 (0)