Skip to content
This repository was archived by the owner on Oct 13, 2023. It is now read-only.

Commit 324307e

Browse files
committed
Improve Ubuntu version detection
1 parent b465142 commit 324307e

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/download.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,19 @@ function getRunner(): string {
2121
case "darwin":
2222
return "macos-10.15";
2323
case "linux":
24-
// TODO: Is there better way to determine Actions runner OS?
25-
if (os.release().startsWith("4.15")) {
26-
return "ubuntu-16.04";
27-
} else {
28-
return "ubuntu-18.04";
24+
for (const line of require("fs")
25+
.readFileSync("/etc/os-release", {
26+
encoding: "utf8",
27+
})
28+
.split("\n")) {
29+
if (line.startsWith("VERSION_ID=")) {
30+
return (
31+
"ubuntu-" + line.substring(10).replaceAll(/["']/g, "")
32+
);
33+
}
2934
}
35+
36+
throw new Error("Unrecognized version of Ubuntu");
3037
default:
3138
throw new Error("Unsupported OS");
3239
}

0 commit comments

Comments
 (0)