10
0
Fork 0
mirror of https://github.com/Azure/setup-helm.git synced 2026-04-14 10:34:47 +00:00

Added comment on getLatestHelmVersion and variable for helm release url to command

This commit is contained in:
Asa Gayle 2022-01-14 09:46:29 -05:00
parent e468b13d6c
commit b34dae9d36
2 changed files with 8 additions and 10 deletions

View file

@ -105,8 +105,9 @@ export async function downloadHelm(version: string): Promise<string> {
return helmpath;
}
// getLatestHelmVersion uses cURL and regex to scrape the latest version
async function getLatestHelmVersion(): Promise<string>{
const command:string = `curl -Ls https://api.github.com/repos/helm/helm/releases | grep 'v3.[0-9]*.[0-9]*' | sed -E 's/ .*\/helm\/helm\/releases\/tag\/tag\/(v[0-9\.]+)".*/\\1/g' | head -1 | sed -E 's/.*tag\///' | sed -E 's/".*//'`;
const command:string = `curl -Ls ${helmAllReleasesUrl} | grep 'v3.[0-9]*.[0-9]*' | sed -E 's/ .*\/helm\/helm\/releases\/tag\/tag\/(v[0-9\.]+)".*/\\1/g' | head -1 | sed -E 's/.*tag\///' | sed -E 's/".*//'`;
let latestHelm: string = "";
let latestHelmErr: string = "";
@ -123,14 +124,12 @@ async function getLatestHelmVersion(): Promise<string>{
await exec.exec(command, [], options);
if(latestHelmErr !== "") return getStableHelmVersion();
if(latestHelmErr !== "" || isValidVersion(latestHelm)) return getStableHelmVersion();
return latestHelm;
}
// isValidVersion checks if verison matches the specified type and is a stable release
function isValidVersion(version: string, type: string): boolean {
if (!version.toLocaleLowerCase().startsWith(type))
return false;
function isValidVersion(version: string): boolean {
return version.indexOf('rc') == -1;
}