-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy pathruntime-release.mjs
More file actions
19 lines (18 loc) · 1 KB
/
Copy pathruntime-release.mjs
File metadata and controls
19 lines (18 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------------------------------------------*/
/**
* Resolve a pinned runtime's public release, preserving the caller's mirror override.
* @param {string} version
* @param {string | null | undefined} [baseUrl] Pass null to ignore ambient mirror settings.
*/
export function runtimeReleaseUrl(version, baseUrl = process.env.COPILOT_CLI_DOWNLOAD_BASE_URL) {
const unstable =
/^(?:0|[1-9][0-9]*)(?:\.(?:0|[1-9][0-9]*)){2}(?:-unstable|-(?:0|[1-9][0-9]*)\.unstable)\.r[1-9][0-9]*\.g[0-9a-f]{7}$/.test(
version,
);
const repository = unstable ? "copilot-sdk" : "copilot-cli";
const tag = unstable ? `runtime-${version}` : `v${version}`;
const base = baseUrl ?? `https://github.com/github/${repository}/releases/download`;
return `${base.replace(/\/+$/, "")}/${tag}`;
}