From d2de35bc239ad5488e01566f3ac6701efc4a5a00 Mon Sep 17 00:00:00 2001 From: cptpcrd <31829097+cptpcrd@users.noreply.github.com> Date: Wed, 25 Nov 2020 18:12:52 -0500 Subject: [PATCH] Improve Ubuntu version detection --- src/download.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/download.ts b/src/download.ts index ba78d6a..1d8d227 100644 --- a/src/download.ts +++ b/src/download.ts @@ -21,12 +21,17 @@ function getRunner(): string { case "darwin": return "macos-10.15"; case "linux": - // TODO: Is there better way to determine Actions runner OS? - if (os.release().startsWith("4.15")) { - return "ubuntu-16.04"; - } else { - return "ubuntu-18.04"; + for (const line of require("fs") + .readFileSync("/etc/os-release", { + encoding: "utf8", + }) + .split("\n")) { + if (line.startsWith("VERSION_ID=")) { + return "ubuntu-" + line.substring(10).replaceAll(/["']/g, ""); + } } + + throw new Error("Unrecognized version of Ubuntu"); default: throw new Error("Unsupported OS"); }