Compare commits

...

15 Commits

Author SHA1 Message Date
Imran Ismail
13cc3947ac Release v1.5.2 2020-10-13 23:01:09 +08:00
dependabot[bot]
548304dcdd Bump @typescript-eslint/parser from 2.34.0 to 4.4.1 (#29)
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 2.34.0 to 4.4.1.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.4.1/packages/parser)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-10-13 22:59:19 +08:00
dependabot[bot]
366ebb426b Bump eslint-plugin-jest from 23.20.0 to 24.1.0 (#22)
Bumps [eslint-plugin-jest](https://github.com/jest-community/eslint-plugin-jest) from 23.20.0 to 24.1.0.
- [Release notes](https://github.com/jest-community/eslint-plugin-jest/releases)
- [Changelog](https://github.com/jest-community/eslint-plugin-jest/blob/master/CHANGELOG.md)
- [Commits](https://github.com/jest-community/eslint-plugin-jest/compare/v23.20.0...v24.1.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-10-13 22:51:51 +08:00
dependabot[bot]
0b4205889c Bump jest-circus from 26.4.2 to 26.5.3 (#28)
Bumps [jest-circus](https://github.com/facebook/jest/tree/HEAD/packages/jest-circus) from 26.4.2 to 26.5.3.
- [Release notes](https://github.com/facebook/jest/releases)
- [Changelog](https://github.com/facebook/jest/blob/master/CHANGELOG.md)
- [Commits](https://github.com/facebook/jest/commits/v26.5.3/packages/jest-circus)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-10-13 22:46:39 +08:00
dependabot[bot]
509da12cc4 Bump @zeit/ncc from 0.20.5 to 0.22.3 (#18)
Bumps [@zeit/ncc](https://github.com/zeit/ncc) from 0.20.5 to 0.22.3.
- [Release notes](https://github.com/zeit/ncc/releases)
- [Commits](https://github.com/zeit/ncc/compare/0.20.5...0.22.3)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-10-13 22:46:09 +08:00
dependabot[bot]
b7c602d150 Bump @types/node from 14.11.2 to 14.11.8 (#27)
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 14.11.2 to 14.11.8.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-10-13 22:44:28 +08:00
Imran Ismail
d6406c9ed5 Update README.md 2020-10-02 01:49:01 +08:00
dependabot[bot]
965f29eaf7 Bump @types/node from 14.10.0 to 14.11.2 (#12)
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 14.10.0 to 14.11.2.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-10-02 01:45:02 +08:00
dependabot[bot]
41e7f9975d Bump @types/jest from 26.0.10 to 26.0.14 (#13)
Bumps [@types/jest](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/jest) from 26.0.10 to 26.0.14.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/jest)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-10-02 01:41:55 +08:00
dependabot[bot]
45c217953c Bump prettier from 2.1.1 to 2.1.2 (#14)
Bumps [prettier](https://github.com/prettier/prettier) from 2.1.1 to 2.1.2.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/master/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/2.1.1...2.1.2)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-10-02 01:41:15 +08:00
dependabot[bot]
ae749a83d7 Bump eslint from 7.8.1 to 7.10.0 (#15)
Bumps [eslint](https://github.com/eslint/eslint) from 7.8.1 to 7.10.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v7.8.1...v7.10.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-10-02 01:40:01 +08:00
dependabot[bot]
0c2f32dde2 Bump typescript from 3.9.7 to 4.0.3 (#11)
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 3.9.7 to 4.0.3.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](https://github.com/Microsoft/TypeScript/compare/v3.9.7...v4.0.3)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-10-02 01:35:36 +08:00
dependabot[bot]
59f3d52ca7 Bump @actions/core from 1.2.5 to 1.2.6 (#16)
Bumps [@actions/core](https://github.com/actions/toolkit/tree/HEAD/packages/core) from 1.2.5 to 1.2.6.
- [Release notes](https://github.com/actions/toolkit/releases)
- [Changelog](https://github.com/actions/toolkit/blob/main/packages/core/RELEASES.md)
- [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/core)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-10-02 01:25:34 +08:00
Imran Ismail
ff25099d8b Update manifests 2020-09-25 22:16:19 +08:00
Imran Ismail
359e84cbc9 Cache by requested version name 2020-09-25 22:14:20 +08:00
9 changed files with 896 additions and 586 deletions

View File

@@ -1,4 +1,10 @@
## TLDR
![build-test](https://github.com/imranismail/setup-kustomize/workflows/build-test/badge.svg)
## Description
Install any kustomize version as a step in your workflow
## Usage
```yaml
on:

View File

@@ -17,18 +17,24 @@ describe('installer tests', () => {
beforeAll(async () => {
await io.rmRF(toolDir)
await io.rmRF(tempDir)
}, 100000)
})
afterAll(async () => {
await io.rmRF(toolDir)
await io.rmRF(tempDir)
}, 100000)
it('Acquires the max satisfying version range', async () => {
await installer.getKustomize('~> 3.0')
const kustomizeDir = path.join(toolDir, 'kustomize', '~> 3.0', os.arch())
expect(fs.existsSync(`${kustomizeDir}.complete`)).toBe(true)
it('Acquires the latest kustomize version 3.x successfully', () => {
expect(async () => await installer.getKustomize('3.x')).not.toThrow()
}, 100000)
if (IS_WINDOWS) {
expect(fs.existsSync(path.join(kustomizeDir, 'kustomize.exe'))).toBe(true)
} else {
expect(fs.existsSync(path.join(kustomizeDir, 'kustomize'))).toBe(true)
expect(() =>
fs.accessSync(path.join(kustomizeDir, 'kustomize'), fs.constants.X_OK)
).not.toThrow()
}
})
it('Acquires kustomize version 3.2.0 successfully', async () => {
it('Acquires kustomize version 3.2.0', async () => {
await installer.getKustomize('3.2.0')
const kustomizeDir = path.join(toolDir, 'kustomize', '3.2.0', os.arch())
@@ -42,9 +48,9 @@ describe('installer tests', () => {
fs.accessSync(path.join(kustomizeDir, 'kustomize'), fs.constants.X_OK)
).not.toThrow()
}
}, 100000)
})
it('Acquires kustomize version 3.2.1 successfully', async () => {
it('Acquires kustomize version 3.2.1', async () => {
await installer.getKustomize('3.2.1')
const kustomizeDir = path.join(toolDir, 'kustomize', '3.2.1', os.arch())
@@ -58,9 +64,9 @@ describe('installer tests', () => {
fs.accessSync(path.join(kustomizeDir, 'kustomize'), fs.constants.X_OK)
).not.toThrow()
}
}, 100000)
})
it('Acquires kustomize version 3.3.0 successfully', async () => {
it('Acquires kustomize version 3.3.0', async () => {
await installer.getKustomize('3.3.0')
const kustomizeDir = path.join(toolDir, 'kustomize', '3.3.0', os.arch())
@@ -74,7 +80,7 @@ describe('installer tests', () => {
fs.accessSync(path.join(kustomizeDir, 'kustomize'), fs.constants.X_OK)
).not.toThrow()
}
}, 100000)
})
it('Throws if no location contains correct kustomize version', async () => {
let thrown = false

161
dist/index.js vendored
View File

@@ -19,7 +19,13 @@ require('./sourcemap-register.js');module.exports =
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ var threw = true;
/******/ try {
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ threw = false;
/******/ } finally {
/******/ if(threw) delete installedModules[moduleId];
/******/ }
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
@@ -1041,9 +1047,9 @@ module.exports = require("tls");
/***/ }),
/***/ 18:
/***/ (function() {
/***/ (function(module) {
eval("require")("encoding");
module.exports = eval("require")("encoding");
/***/ }),
@@ -1505,6 +1511,32 @@ class SemVer {
module.exports = SemVer
/***/ }),
/***/ 82:
/***/ (function(__unusedmodule, exports) {
"use strict";
// We use any as a valid input type
/* eslint-disable @typescript-eslint/no-explicit-any */
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Sanitizes an input into a string so it can be passed into issueCommand safely
* @param input input to sanitize into a string
*/
function toCommandValue(input) {
if (input === null || input === undefined) {
return '';
}
else if (typeof input === 'string' || input instanceof String) {
return input;
}
return JSON.stringify(input);
}
exports.toCommandValue = toCommandValue;
//# sourceMappingURL=utils.js.map
/***/ }),
/***/ 87:
@@ -1514,6 +1546,42 @@ module.exports = require("os");
/***/ }),
/***/ 102:
/***/ (function(__unusedmodule, exports, __webpack_require__) {
"use strict";
// For internal use, subject to change.
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
// We use any as a valid input type
/* eslint-disable @typescript-eslint/no-explicit-any */
const fs = __importStar(__webpack_require__(747));
const os = __importStar(__webpack_require__(87));
const utils_1 = __webpack_require__(82);
function issueCommand(command, message) {
const filePath = process.env[`GITHUB_${command}`];
if (!filePath) {
throw new Error(`Unable to find environment variable for file command ${command}`);
}
if (!fs.existsSync(filePath)) {
throw new Error(`Missing file at path: ${filePath}`);
}
fs.appendFileSync(filePath, `${utils_1.toCommandValue(message)}${os.EOL}`, {
encoding: 'utf8'
});
}
exports.issueCommand = issueCommand;
//# sourceMappingURL=file-command.js.map
/***/ }),
/***/ 120:
/***/ (function(module, __unusedexports, __webpack_require__) {
@@ -2552,7 +2620,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
@@ -3267,6 +3335,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
};
Object.defineProperty(exports, "__esModule", { value: true });
const os = __importStar(__webpack_require__(87));
const utils_1 = __webpack_require__(82);
/**
* Commands
*
@@ -3320,28 +3389,14 @@ class Command {
return cmdStr;
}
}
/**
* Sanitizes an input into a string so it can be passed into issueCommand safely
* @param input input to sanitize into a string
*/
function toCommandValue(input) {
if (input === null || input === undefined) {
return '';
}
else if (typeof input === 'string' || input instanceof String) {
return input;
}
return JSON.stringify(input);
}
exports.toCommandValue = toCommandValue;
function escapeData(s) {
return toCommandValue(s)
return utils_1.toCommandValue(s)
.replace(/%/g, '%25')
.replace(/\r/g, '%0D')
.replace(/\n/g, '%0A');
}
function escapeProperty(s) {
return toCommandValue(s)
return utils_1.toCommandValue(s)
.replace(/%/g, '%25')
.replace(/\r/g, '%0D')
.replace(/\n/g, '%0A')
@@ -5390,6 +5445,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
};
Object.defineProperty(exports, "__esModule", { value: true });
const command_1 = __webpack_require__(431);
const file_command_1 = __webpack_require__(102);
const utils_1 = __webpack_require__(82);
const os = __importStar(__webpack_require__(87));
const path = __importStar(__webpack_require__(622));
/**
@@ -5416,9 +5473,17 @@ var ExitCode;
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function exportVariable(name, val) {
const convertedVal = command_1.toCommandValue(val);
const convertedVal = utils_1.toCommandValue(val);
process.env[name] = convertedVal;
command_1.issueCommand('set-env', { name }, convertedVal);
const filePath = process.env['GITHUB_ENV'] || '';
if (filePath) {
const delimiter = '_GitHubActionsFileCommandDelimeter_';
const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;
file_command_1.issueCommand('ENV', commandValue);
}
else {
command_1.issueCommand('set-env', { name }, convertedVal);
}
}
exports.exportVariable = exportVariable;
/**
@@ -5434,7 +5499,13 @@ exports.setSecret = setSecret;
* @param inputPath
*/
function addPath(inputPath) {
command_1.issueCommand('add-path', {}, inputPath);
const filePath = process.env['GITHUB_PATH'] || '';
if (filePath) {
file_command_1.issueCommand('PATH', inputPath);
}
else {
command_1.issueCommand('add-path', {}, inputPath);
}
process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;
}
exports.addPath = addPath;
@@ -9057,7 +9128,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
@@ -9108,23 +9179,24 @@ if (!tempDirectory) {
}
tempDirectory = path.join(baseLocation, 'actions', 'temp');
}
function getKustomize(versionSpec) {
function getKustomize(targetVersion) {
return __awaiter(this, void 0, void 0, function* () {
let toolPath = cache.find('kustomize', versionSpec);
if (!toolPath) {
const version = yield getMaxSatisfyingVersion(versionSpec);
toolPath = yield acquireVersion(version);
if (!semver.validRange(targetVersion))
throw new Error(`invalid semver requested: ${targetVersion}`);
let kustomizePath = cache.find('kustomize', targetVersion);
if (!kustomizePath) {
const version = yield getMaxSatisfyingVersion(targetVersion);
kustomizePath = yield acquireVersion(version);
}
return core.addPath(toolPath);
return core.addPath(kustomizePath);
});
}
exports.getKustomize = getKustomize;
function getMaxSatisfyingVersion(versionSpec) {
function getMaxSatisfyingVersion(targetVersion) {
var e_1, _a;
return __awaiter(this, void 0, void 0, function* () {
const versionRange = semver.validRange(versionSpec);
const downloadUrls = new Map();
const versions = [];
const version = { target: targetVersion };
const availableVersions = new Map();
try {
for (var _b = __asyncValues(octokit.paginate.iterator(octokit.repos.listReleases, {
owner: 'kubernetes-sigs',
@@ -9136,10 +9208,9 @@ function getMaxSatisfyingVersion(versionSpec) {
asset.name.includes(platform) &&
asset.name.includes(arch));
if (matchingAsset) {
const version = (versionRegex.exec(release.name) || []).shift();
if (version != null) {
downloadUrls.set(version, matchingAsset.browser_download_url);
versions.push(version);
const kustomizeVersion = (versionRegex.exec(release.name) || []).shift();
if (kustomizeVersion != null) {
availableVersions.set(kustomizeVersion, matchingAsset.browser_download_url);
}
}
}
@@ -9152,12 +9223,12 @@ function getMaxSatisfyingVersion(versionSpec) {
}
finally { if (e_1) throw e_1.error; }
}
const versionToDownload = semver.maxSatisfying(versions, versionRange);
if (!versionToDownload) {
throw new Error(`Unable to find Kustomize version '${versionSpec}' for platform '${platform}' and architecture ${arch}.`);
const resolved = semver.maxSatisfying([...availableVersions.keys()], version.target);
if (!resolved) {
throw new Error(`Unable to find Kustomize version '${version.target}' for platform '${platform}' and architecture ${arch}.`);
}
const downloadUrl = downloadUrls.get(versionToDownload);
return { name: versionToDownload, url: downloadUrl };
const url = availableVersions.get(resolved);
return Object.assign(Object.assign({}, version), { resolved, url });
});
}
function acquireVersion(version) {
@@ -9169,7 +9240,7 @@ function acquireVersion(version) {
}
catch (err) {
core.debug(err);
throw new Error(`Failed to download version ${version.name}: ${err}`);
throw new Error(`Failed to download version ${version.target}: ${err}`);
}
if (version.url.endsWith('.tar.gz')) {
toolPath = yield cache.extractTar(toolPath);
@@ -9181,7 +9252,7 @@ function acquireVersion(version) {
fs.chmodSync(toolPath, 0o755);
break;
}
return yield cache.cacheFile(toolPath, toolFilename, toolName, version.name);
return yield cache.cacheFile(toolPath, toolFilename, toolName, version.target);
});
}

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@@ -19,7 +19,13 @@ module.exports =
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ var threw = true;
/******/ try {
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ threw = false;
/******/ } finally {
/******/ if(threw) delete installedModules[moduleId];
/******/ }
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;

View File

@@ -4,8 +4,9 @@ module.exports = {
testEnvironment: 'node',
testMatch: ['**/*.test.ts'],
testRunner: 'jest-circus/runner',
testTimeout: 60000,
transform: {
'^.+\\.ts$': 'ts-jest'
},
verbose: true
}
}

1192
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -25,26 +25,26 @@
"author": "Imran Ismail",
"license": "MIT",
"dependencies": {
"@actions/core": "^1.2.4",
"@actions/core": "^1.2.6",
"@actions/io": "^1.0.2",
"@actions/tool-cache": "^1.3.3",
"@octokit/rest": "^18.0.6",
"semver": "^7.3.2"
},
"devDependencies": {
"@types/jest": "^26.0.5",
"@types/node": "^14.0.23",
"@types/jest": "^26.0.14",
"@types/node": "^14.11.8",
"@types/semver": "^7.3.4",
"@typescript-eslint/parser": "^2.8.0",
"@zeit/ncc": "^0.20.5",
"eslint": "^7.5.0",
"@typescript-eslint/parser": "^4.4.1",
"@zeit/ncc": "^0.22.3",
"eslint": "^7.10.0",
"eslint-plugin-github": "^4.0.1",
"eslint-plugin-jest": "^23.18.0",
"eslint-plugin-jest": "^24.1.0",
"jest": "^24.9.0",
"jest-circus": "^26.1.0",
"jest-circus": "^26.5.3",
"js-yaml": "^3.13.1",
"prettier": "^2.0.5",
"prettier": "^2.1.2",
"ts-jest": "^24.2.0",
"typescript": "^3.9.4"
"typescript": "^4.0.3"
}
}

View File

@@ -28,26 +28,31 @@ if (!tempDirectory) {
tempDirectory = path.join(baseLocation, 'actions', 'temp')
}
export async function getKustomize(versionSpec: string): Promise<void> {
let toolPath = cache.find('kustomize', versionSpec)
export async function getKustomize(targetVersion: string): Promise<void> {
if (!semver.validRange(targetVersion))
throw new Error(`invalid semver requested: ${targetVersion}`)
if (!toolPath) {
const version = await getMaxSatisfyingVersion(versionSpec)
toolPath = await acquireVersion(version)
let kustomizePath = cache.find('kustomize', targetVersion)
if (!kustomizePath) {
const version = await getMaxSatisfyingVersion(targetVersion)
kustomizePath = await acquireVersion(version)
}
return core.addPath(toolPath)
return core.addPath(kustomizePath)
}
interface Version {
name: string
resolved: string
target: string
url: string
}
async function getMaxSatisfyingVersion(versionSpec: string): Promise<Version> {
const versionRange = semver.validRange(versionSpec)
const downloadUrls: Map<string, string> = new Map()
const versions: string[] = []
async function getMaxSatisfyingVersion(
targetVersion: string
): Promise<Version> {
const version = {target: targetVersion}
const availableVersions: Map<string, string> = new Map()
for await (const response of octokit.paginate.iterator(
octokit.repos.listReleases,
@@ -65,27 +70,32 @@ async function getMaxSatisfyingVersion(versionSpec: string): Promise<Version> {
)
if (matchingAsset) {
const version = (versionRegex.exec(release.name) || []).shift()
const kustomizeVersion = (versionRegex.exec(release.name) || []).shift()
if (version != null) {
downloadUrls.set(version, matchingAsset.browser_download_url)
versions.push(version)
if (kustomizeVersion != null) {
availableVersions.set(
kustomizeVersion,
matchingAsset.browser_download_url
)
}
}
}
}
const versionToDownload = semver.maxSatisfying(versions, versionRange)
const resolved = semver.maxSatisfying(
[...availableVersions.keys()],
version.target
)
if (!versionToDownload) {
if (!resolved) {
throw new Error(
`Unable to find Kustomize version '${versionSpec}' for platform '${platform}' and architecture ${arch}.`
`Unable to find Kustomize version '${version.target}' for platform '${platform}' and architecture ${arch}.`
)
}
const downloadUrl = downloadUrls.get(versionToDownload) as string
const url = availableVersions.get(resolved) as string
return {name: versionToDownload, url: downloadUrl}
return {...version, resolved, url}
}
async function acquireVersion(version: Version): Promise<string> {
@@ -97,7 +107,7 @@ async function acquireVersion(version: Version): Promise<string> {
toolPath = await cache.downloadTool(version.url)
} catch (err) {
core.debug(err)
throw new Error(`Failed to download version ${version.name}: ${err}`)
throw new Error(`Failed to download version ${version.target}: ${err}`)
}
if (version.url.endsWith('.tar.gz')) {
@@ -112,5 +122,5 @@ async function acquireVersion(version: Version): Promise<string> {
break
}
return await cache.cacheFile(toolPath, toolFilename, toolName, version.name)
return await cache.cacheFile(toolPath, toolFilename, toolName, version.target)
}