mirror of
https://github.com/Azure/setup-helm.git
synced 2025-12-21 14:55:43 +00:00
Compare commits
8 Commits
update-rea
...
mergetomas
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e045d11f39 | ||
|
|
b1c4524a5f | ||
|
|
f404b8932e | ||
|
|
1de6b70ec6 | ||
|
|
d0d63812ab | ||
|
|
87a2cd59a0 | ||
|
|
fe2c706cad | ||
|
|
11c996f4c7 |
@@ -1,7 +1,7 @@
|
|||||||
# Setup Helm
|
# Setup Helm
|
||||||
#### Install a specific version of helm binary on the runner.
|
#### Install a specific version of helm binary on the runner.
|
||||||
|
|
||||||
Acceptable values are latest or any semantic version string like 1.15.0. Use this action in workflow to define which version of helm will be used.
|
Acceptable values are latest or any semantic version string like v2.16.7 Use this action in workflow to define which version of helm will be used.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- uses: azure/setup-helm@v1
|
- uses: azure/setup-helm@v1
|
||||||
@@ -9,6 +9,8 @@ Acceptable values are latest or any semantic version string like 1.15.0. Use thi
|
|||||||
version: '<version>' # default is latest stable
|
version: '<version>' # default is latest stable
|
||||||
id: install
|
id: install
|
||||||
```
|
```
|
||||||
|
|
||||||
|
The cached helm binary path is prepended to the PATH environment variable as well as stored in the helm-path output variable.
|
||||||
Refer to the action metadata file for details about all the inputs https://github.com/Azure/setup-helm/blob/master/action.yml
|
Refer to the action metadata file for details about all the inputs https://github.com/Azure/setup-helm/blob/master/action.yml
|
||||||
|
|
||||||
# Contributing
|
# Contributing
|
||||||
|
|||||||
49
lib/run.js
49
lib/run.js
@@ -22,11 +22,12 @@ const os = __importStar(require("os"));
|
|||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
const util = __importStar(require("util"));
|
const util = __importStar(require("util"));
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const toolCache = __importStar(require("../node_modules/@actions/tool-cache"));
|
const semver = __importStar(require("semver"));
|
||||||
const core = __importStar(require("../node_modules/@actions/core"));
|
const toolCache = __importStar(require("@actions/tool-cache"));
|
||||||
|
const core = __importStar(require("@actions/core"));
|
||||||
const helmToolName = 'helm';
|
const helmToolName = 'helm';
|
||||||
const stableHelmVersion = 'v2.14.1';
|
const stableHelmVersion = 'v3.2.1';
|
||||||
const helmLatestReleaseUrl = 'https://api.github.com/repos/helm/helm/releases/latest';
|
const helmAllReleasesUrl = 'https://api.github.com/repos/helm/helm/releases';
|
||||||
function getExecutableExtension() {
|
function getExecutableExtension() {
|
||||||
if (os.type().match(/^Win/)) {
|
if (os.type().match(/^Win/)) {
|
||||||
return '.exe';
|
return '.exe';
|
||||||
@@ -46,17 +47,28 @@ function getHelmDownloadURL(version) {
|
|||||||
}
|
}
|
||||||
function getStableHelmVersion() {
|
function getStableHelmVersion() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
return toolCache.downloadTool(helmLatestReleaseUrl).then((downloadPath) => {
|
try {
|
||||||
const response = JSON.parse(fs.readFileSync(downloadPath, 'utf8').toString().trim());
|
const downloadPath = yield toolCache.downloadTool(helmAllReleasesUrl);
|
||||||
if (!response.tag_name) {
|
const responseArray = JSON.parse(fs.readFileSync(downloadPath, 'utf8').toString().trim());
|
||||||
return stableHelmVersion;
|
let latestHelmVersion = semver.clean(stableHelmVersion);
|
||||||
|
responseArray.forEach(response => {
|
||||||
|
if (response && response.tag_name) {
|
||||||
|
let currentHelmVerison = semver.clean(response.tag_name.toString());
|
||||||
|
if (currentHelmVerison) {
|
||||||
|
if (currentHelmVerison.toString().indexOf('rc') == -1 && semver.gt(currentHelmVerison, latestHelmVersion)) {
|
||||||
|
//If current helm version is not a pre release and is greater than latest helm version
|
||||||
|
latestHelmVersion = currentHelmVerison;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return response.tag_name;
|
|
||||||
}, (error) => {
|
|
||||||
core.debug(error);
|
|
||||||
core.warning(util.format("Failed to read latest kubectl version from stable.txt. From URL %s. Using default stable version %s", helmLatestReleaseUrl, stableHelmVersion));
|
|
||||||
return stableHelmVersion;
|
|
||||||
});
|
});
|
||||||
|
latestHelmVersion = "v" + latestHelmVersion;
|
||||||
|
return latestHelmVersion;
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
core.warning(util.format("Cannot get the latest Helm info from %s. Error %s. Using default Helm version %s.", helmAllReleasesUrl, error, stableHelmVersion));
|
||||||
|
}
|
||||||
|
return stableHelmVersion;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
var walkSync = function (dir, filelist, fileToFind) {
|
var walkSync = function (dir, filelist, fileToFind) {
|
||||||
@@ -118,7 +130,18 @@ function run() {
|
|||||||
if (version.toLocaleLowerCase() === 'latest') {
|
if (version.toLocaleLowerCase() === 'latest') {
|
||||||
version = yield getStableHelmVersion();
|
version = yield getStableHelmVersion();
|
||||||
}
|
}
|
||||||
|
else if (!version.toLocaleLowerCase().startsWith('v')) {
|
||||||
|
version = 'v' + version;
|
||||||
|
}
|
||||||
let cachedPath = yield downloadHelm(version);
|
let cachedPath = yield downloadHelm(version);
|
||||||
|
try {
|
||||||
|
if (!process.env['PATH'].startsWith(path.dirname(cachedPath))) {
|
||||||
|
core.addPath(path.dirname(cachedPath));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (_a) {
|
||||||
|
//do nothing, set as output variable
|
||||||
|
}
|
||||||
console.log(`Helm tool version: '${version}' has been cached at ${cachedPath}`);
|
console.log(`Helm tool version: '${version}' has been cached at ${cachedPath}`);
|
||||||
core.setOutput('helm-path', cachedPath);
|
core.setOutput('helm-path', cachedPath);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -9,7 +9,8 @@
|
|||||||
"@actions/tool-cache": "1.1.2",
|
"@actions/tool-cache": "1.1.2",
|
||||||
"@actions/io": "^1.0.0",
|
"@actions/io": "^1.0.0",
|
||||||
"@actions/core": "^1.0.0",
|
"@actions/core": "^1.0.0",
|
||||||
"@actions/exec": "^1.0.0"
|
"@actions/exec": "^1.0.0",
|
||||||
|
"semver": "^6.1.0"
|
||||||
},
|
},
|
||||||
"main": "lib/run.js",
|
"main": "lib/run.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
50
src/run.ts
50
src/run.ts
@@ -5,13 +5,14 @@ import * as os from 'os';
|
|||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as util from 'util';
|
import * as util from 'util';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
|
import * as semver from 'semver';
|
||||||
|
|
||||||
import * as toolCache from '@actions/tool-cache';
|
import * as toolCache from '@actions/tool-cache';
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
|
|
||||||
const helmToolName = 'helm';
|
const helmToolName = 'helm';
|
||||||
const stableHelmVersion = 'v2.14.1';
|
const stableHelmVersion = 'v3.2.1';
|
||||||
const helmLatestReleaseUrl = 'https://api.github.com/repos/helm/helm/releases/latest';
|
const helmAllReleasesUrl = 'https://api.github.com/repos/helm/helm/releases';
|
||||||
|
|
||||||
function getExecutableExtension(): string {
|
function getExecutableExtension(): string {
|
||||||
if (os.type().match(/^Win/)) {
|
if (os.type().match(/^Win/)) {
|
||||||
@@ -36,19 +37,28 @@ function getHelmDownloadURL(version: string): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function getStableHelmVersion(): Promise<string> {
|
async function getStableHelmVersion(): Promise<string> {
|
||||||
return toolCache.downloadTool(helmLatestReleaseUrl).then((downloadPath) => {
|
try {
|
||||||
const response = JSON.parse(fs.readFileSync(downloadPath, 'utf8').toString().trim());
|
const downloadPath = await toolCache.downloadTool(helmAllReleasesUrl);
|
||||||
if (!response.tag_name)
|
const responseArray = JSON.parse(fs.readFileSync(downloadPath, 'utf8').toString().trim());
|
||||||
{
|
let latestHelmVersion = semver.clean(stableHelmVersion);
|
||||||
return stableHelmVersion;
|
responseArray.forEach(response => {
|
||||||
|
if (response && response.tag_name) {
|
||||||
|
let currentHelmVerison = semver.clean(response.tag_name.toString());
|
||||||
|
if (currentHelmVerison) {
|
||||||
|
if (currentHelmVerison.toString().indexOf('rc') == -1 && semver.gt(currentHelmVerison, latestHelmVersion)) {
|
||||||
|
//If current helm version is not a pre release and is greater than latest helm version
|
||||||
|
latestHelmVersion = currentHelmVerison;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
latestHelmVersion = "v" + latestHelmVersion;
|
||||||
|
return latestHelmVersion;
|
||||||
|
} catch (error) {
|
||||||
|
core.warning(util.format("Cannot get the latest Helm info from %s. Error %s. Using default Helm version %s.", helmAllReleasesUrl, error, stableHelmVersion));
|
||||||
}
|
}
|
||||||
|
|
||||||
return response.tag_name;
|
|
||||||
}, (error) => {
|
|
||||||
core.debug(error);
|
|
||||||
core.warning(util.format("Failed to read latest kubectl version from stable.txt. From URL %s. Using default stable version %s", helmLatestReleaseUrl, stableHelmVersion));
|
|
||||||
return stableHelmVersion;
|
return stableHelmVersion;
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -61,8 +71,7 @@ var walkSync = function(dir, filelist, fileToFind) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
core.debug(file);
|
core.debug(file);
|
||||||
if(file == fileToFind)
|
if (file == fileToFind) {
|
||||||
{
|
|
||||||
filelist.push(path.join(dir, file));
|
filelist.push(path.join(dir, file));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -111,9 +120,22 @@ async function run() {
|
|||||||
let version = core.getInput('version', { 'required': true });
|
let version = core.getInput('version', { 'required': true });
|
||||||
if (version.toLocaleLowerCase() === 'latest') {
|
if (version.toLocaleLowerCase() === 'latest') {
|
||||||
version = await getStableHelmVersion();
|
version = await getStableHelmVersion();
|
||||||
|
} else if (!version.toLocaleLowerCase().startsWith('v')) {
|
||||||
|
version = 'v' + version;
|
||||||
}
|
}
|
||||||
|
|
||||||
let cachedPath = await downloadHelm(version);
|
let cachedPath = await downloadHelm(version);
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
if (!process.env['PATH'].startsWith(path.dirname(cachedPath))) {
|
||||||
|
core.addPath(path.dirname(cachedPath));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
//do nothing, set as output variable
|
||||||
|
}
|
||||||
|
|
||||||
console.log(`Helm tool version: '${version}' has been cached at ${cachedPath}`);
|
console.log(`Helm tool version: '${version}' has been cached at ${cachedPath}`);
|
||||||
core.setOutput('helm-path', cachedPath);
|
core.setOutput('helm-path', cachedPath);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
|
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
|
||||||
|
|
||||||
/* Strict Type-Checking Options */
|
/* Strict Type-Checking Options */
|
||||||
"strict": true, /* Enable all strict type-checking options. */
|
//"strict": true, /* Enable all strict type-checking options. */
|
||||||
"noImplicitAny": false, /* Raise error on expressions and declarations with an implied 'any' type. */
|
"noImplicitAny": false, /* Raise error on expressions and declarations with an implied 'any' type. */
|
||||||
// "strictNullChecks": true, /* Enable strict null checks. */
|
// "strictNullChecks": true, /* Enable strict null checks. */
|
||||||
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
|
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
|
||||||
|
|||||||
Reference in New Issue
Block a user