mirror of
https://github.com/Azure/setup-helm.git
synced 2025-09-09 13:36:37 +00:00
Fixing PR comments in release
This commit is contained in:
12
lib/run.js
12
lib/run.js
@ -39,6 +39,8 @@ const core = __importStar(require("@actions/core"));
|
|||||||
const graphql_1 = require("@octokit/graphql");
|
const graphql_1 = require("@octokit/graphql");
|
||||||
const helmToolName = 'helm';
|
const helmToolName = 'helm';
|
||||||
const stableHelmVersion = 'v3.2.1';
|
const stableHelmVersion = 'v3.2.1';
|
||||||
|
const stableHelm3Version = 'v3.5.3';
|
||||||
|
const stableHelm2Version = 'v2.17.0';
|
||||||
const LATEST_HELM2_VERSION = '2.*';
|
const LATEST_HELM2_VERSION = '2.*';
|
||||||
const LATEST_HELM3_VERSION = '3.*';
|
const LATEST_HELM3_VERSION = '3.*';
|
||||||
function getExecutableExtension() {
|
function getExecutableExtension() {
|
||||||
@ -123,12 +125,16 @@ function getLatestHelmVersionFor(type) {
|
|||||||
return latestValidRelease.tagName;
|
return latestValidRelease.tagName;
|
||||||
}
|
}
|
||||||
catch (err) {
|
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));
|
core.warning(util.format("Could not find stable release for Helm %s. Using default Helm version %s.", type, getStableHelmVersionFor(type)));
|
||||||
return stableHelmVersion;
|
return getStableHelmVersionFor(type);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
function getStableHelmVersionFor(type) {
|
||||||
|
return type === "v2" ? stableHelm2Version : stableHelm3Version;
|
||||||
|
}
|
||||||
// isValidVersion checks if verison matches the specified type and is a stable release
|
// isValidVersion checks if verison matches the specified type and is a stable release
|
||||||
function isValidVersion(version, type) {
|
function isValidVersion(version, type) {
|
||||||
if (!version.toLocaleLowerCase().startsWith(type))
|
if (!version.toLocaleLowerCase().startsWith(type))
|
||||||
|
55
src/run.ts
55
src/run.ts
@ -12,6 +12,8 @@ import { graphql } from '@octokit/graphql';
|
|||||||
|
|
||||||
const helmToolName = 'helm';
|
const helmToolName = 'helm';
|
||||||
const stableHelmVersion = 'v3.2.1';
|
const stableHelmVersion = 'v3.2.1';
|
||||||
|
const stableHelm3Version = 'v3.5.3';
|
||||||
|
const stableHelm2Version = 'v2.17.0';
|
||||||
const LATEST_HELM2_VERSION = '2.*';
|
const LATEST_HELM2_VERSION = '2.*';
|
||||||
const LATEST_HELM3_VERSION = '3.*';
|
const LATEST_HELM3_VERSION = '3.*';
|
||||||
|
|
||||||
@ -78,11 +80,11 @@ async function downloadHelm(version: string): Promise<string> {
|
|||||||
return helmpath;
|
return helmpath;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getLatestHelmVersionFor(type) {
|
async function getLatestHelmVersionFor(type: string): Promise<string> {
|
||||||
const token = core.getInput('token', { 'required': true });
|
const token = core.getInput('token', { 'required': true });
|
||||||
try {
|
try {
|
||||||
const { repository } = await graphql(
|
const { repository } = await graphql(
|
||||||
`{
|
`{
|
||||||
repository(name:"helm", owner:"helm") {
|
repository(name:"helm", owner:"helm") {
|
||||||
releases(last: 100) {
|
releases(last: 100) {
|
||||||
nodes {
|
nodes {
|
||||||
@ -91,29 +93,34 @@ async function getLatestHelmVersionFor(type) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}`,
|
}`,
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
authorization: `token ${token}`
|
authorization: `token ${token}`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
const releases = repository.releases.nodes.reverse();
|
const releases = repository.releases.nodes.reverse();
|
||||||
let latestValidRelease = releases.find(release => isValidVersion(release.tagName, type));
|
let latestValidRelease = releases.find(release => isValidVersion(release.tagName, type));
|
||||||
if(latestValidRelease)
|
if (latestValidRelease)
|
||||||
return latestValidRelease.tagName;
|
return latestValidRelease.tagName;
|
||||||
} catch (err) {
|
} 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
|
// 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))
|
if (!version.toLocaleLowerCase().startsWith(type))
|
||||||
return false;
|
return false;
|
||||||
return version.indexOf('rc') == -1
|
return version.indexOf('rc') == -1
|
||||||
}
|
}
|
||||||
|
|
||||||
function findHelm(rootFolder: string): string {
|
function findHelm(rootFolder: string): string {
|
||||||
|
Reference in New Issue
Block a user