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

Commit f2506da

Browse files
committed
Improve Ubuntu version detection
1 parent b465142 commit f2506da

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/download.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,17 @@ 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 "ubuntu-" + line.substring(10).replaceAll(/"/g, "");
31+
}
2932
}
33+
34+
throw new Error("Unrecognized version of Ubuntu");
3035
default:
3136
throw new Error("Unsupported OS");
3237
}

0 commit comments

Comments
 (0)