diff --git a/lib/run.js b/lib/run.js index c7d06d9..dabd743 100644 --- a/lib/run.js +++ b/lib/run.js @@ -39,6 +39,8 @@ const core = __importStar(require("@actions/core")); const graphql_1 = require("@octokit/graphql"); const helmToolName = 'helm'; const stableHelmVersion = 'v3.2.1'; +const stableHelm3Version = 'v3.5.3'; +const stableHelm2Version = 'v2.17.0'; const LATEST_HELM2_VERSION = '2.*'; const LATEST_HELM3_VERSION = '3.*'; function getExecutableExtension() { @@ -123,12 +125,16 @@ function getLatestHelmVersionFor(type) { return latestValidRelease.tagName; } catch (err) { - core.warning(util.format("Error while fetching the latest Helm %s release. Error: %s. Using default Helm version %s.", type, err.toString(), stableHelmVersion)); + core.warning(util.format("Error while fetching the latest Helm %s release. Error: %s. Using default Helm version %s.", type, err.toString(), getStableHelmVersionFor(type))); + return getStableHelmVersionFor(type); } - core.warning(util.format("Could not find stable release for Helm %s. Using default Helm version %s.", type, stableHelmVersion)); - return stableHelmVersion; + core.warning(util.format("Could not find stable release for Helm %s. Using default Helm version %s.", type, getStableHelmVersionFor(type))); + return getStableHelmVersionFor(type); }); } +function getStableHelmVersionFor(type) { + return type === "v2" ? stableHelm2Version : stableHelm3Version; +} // isValidVersion checks if verison matches the specified type and is a stable release function isValidVersion(version, type) { if (!version.toLocaleLowerCase().startsWith(type)) @@ -172,4 +178,4 @@ function run() { core.setOutput('helm-path', cachedPath); }); } -run().catch(core.setFailed); \ No newline at end of file +run().catch(core.setFailed); diff --git a/src/run.ts b/src/run.ts index 05bdd8e..48b3432 100644 --- a/src/run.ts +++ b/src/run.ts @@ -12,6 +12,8 @@ import { graphql } from '@octokit/graphql'; const helmToolName = 'helm'; const stableHelmVersion = 'v3.2.1'; +const stableHelm3Version = 'v3.5.3'; +const stableHelm2Version = 'v2.17.0'; const LATEST_HELM2_VERSION = '2.*'; const LATEST_HELM3_VERSION = '3.*'; @@ -78,7 +80,7 @@ async function downloadHelm(version: string): Promise { return helmpath; } -async function getLatestHelmVersionFor(type) { +async function getLatestHelmVersionFor(type: string): Promise { const token = core.getInput('token', { 'required': true }); try { const { repository } = await graphql( @@ -103,14 +105,19 @@ async function getLatestHelmVersionFor(type) { if (latestValidRelease) return latestValidRelease.tagName; } catch (err) { - core.warning(util.format("Error while fetching the latest Helm %s release. Error: %s. Using default Helm version %s.", type, err.toString(), stableHelmVersion)); + core.warning(util.format("Error while fetching the latest Helm %s release. Error: %s. Using default Helm version %s.", type, err.toString(), getStableHelmVersionFor(type))); + return getStableHelmVersionFor(type); } - core.warning(util.format("Could not find stable release for Helm %s. Using default Helm version %s.", type, stableHelmVersion)); - return stableHelmVersion; + core.warning(util.format("Could not find stable release for Helm %s. Using default Helm version %s.", type, getStableHelmVersionFor(type))); + return getStableHelmVersionFor(type); +} + +function getStableHelmVersionFor(type: string) { + return type==="v2" ? stableHelm2Version : stableHelm3Version; } // isValidVersion checks if verison matches the specified type and is a stable release -function isValidVersion(version, type): boolean { +function isValidVersion(version: string, type: string): boolean { if (!version.toLocaleLowerCase().startsWith(type)) return false; return version.indexOf('rc') == -1