-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.ts
31 lines (24 loc) · 1.19 KB
/
main.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import * as core from "@actions/core";
import * as tc from "@actions/tool-cache";
import * as path from "path";
const isWin = /^win/.test(process.platform);
const isMac = process.platform === "darwin";
export const dartOS = isWin ? "windows" : (isMac ? "macos" : "linux");
async function run() {
try {
const dartChannel = core.getInput("channel", { required: true });
const releaseType = dartChannel === "be" ? "raw" : "release";
const url = `https://storage.googleapis.com/dart-archive/channels/${dartChannel}/${releaseType}/latest/sdk/dartsdk-${dartOS}-x64-release.zip`;
const dartZipPath = await tc.downloadTool(url);
// TODO: Cache?
// https://github.com/actions/toolkit/tree/master/packages/tool-cache
const dartSdkPath = await tc.extractZip(dartZipPath);
core.addPath(path.join(dartSdkPath, "dart-sdk", "bin"));
core.setOutput("dart-sdk", dartSdkPath);
} catch (error: any) { // eslint-disable-line @typescript-eslint/no-explicit-any
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
const errorMessage = "message" in error ? error.message : error;
core.setFailed(errorMessage ?? "<unknown error>");
}
}
void run();