Skip to content
This repository was archived by the owner on Apr 14, 2023. It is now read-only.

Commit 4c032f5

Browse files
author
GitHub Actions
committed
chore(build): 🧱 build [skip ci]
1 parent 20c377b commit 4c032f5

File tree

1 file changed

+185
-6
lines changed

1 file changed

+185
-6
lines changed

‎dist/index.js‎

Lines changed: 185 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@ module.exports =
2020
/******/ };
2121
/******/
2222
/******/ // Execute the module function
23-
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
23+
/******/ var threw = true;
24+
/******/ try {
25+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
26+
/******/ threw = false;
27+
/******/ } finally {
28+
/******/ if(threw) delete installedModules[moduleId];
29+
/******/ }
2430
/******/
2531
/******/ // Flag the module as loaded
2632
/******/ module.l = true;
@@ -955,6 +961,119 @@ module.exports = require("tls");
955961

956962
/***/ }),
957963

964+
/***/ 31:
965+
/***/ (function(module, exports, __webpack_require__) {
966+
967+
"use strict";
968+
969+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
970+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
971+
return new (P || (P = Promise))(function (resolve, reject) {
972+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
973+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
974+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
975+
step((generator = generator.apply(thisArg, _arguments || [])).next());
976+
});
977+
};
978+
var __importStar = (this && this.__importStar) || function (mod) {
979+
if (mod && mod.__esModule) return mod;
980+
var result = {};
981+
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
982+
result["default"] = mod;
983+
return result;
984+
};
985+
Object.defineProperty(exports, "__esModule", { value: true });
986+
const semver = __importStar(__webpack_require__(280));
987+
const core_1 = __webpack_require__(470);
988+
// needs to be require for core node modules to be mocked
989+
/* eslint @typescript-eslint/no-require-imports: 0 */
990+
const os = __webpack_require__(87);
991+
const cp = __webpack_require__(129);
992+
const fs = __webpack_require__(747);
993+
function _findMatch(versionSpec, stable, candidates, archFilter) {
994+
return __awaiter(this, void 0, void 0, function* () {
995+
const platFilter = os.platform();
996+
let result;
997+
let match;
998+
let file;
999+
for (const candidate of candidates) {
1000+
const version = candidate.version;
1001+
core_1.debug(`check ${version} satisfies ${versionSpec}`);
1002+
if (semver.satisfies(version, versionSpec) &&
1003+
(!stable || candidate.stable === stable)) {
1004+
file = candidate.files.find(item => {
1005+
core_1.debug(`${item.arch}===${archFilter} && ${item.platform}===${platFilter}`);
1006+
let chk = item.arch === archFilter && item.platform === platFilter;
1007+
if (chk && item.platform_version) {
1008+
const osVersion = module.exports._getOsVersion();
1009+
if (osVersion === item.platform_version) {
1010+
chk = true;
1011+
}
1012+
else {
1013+
chk = semver.satisfies(osVersion, item.platform_version);
1014+
}
1015+
}
1016+
return chk;
1017+
});
1018+
if (file) {
1019+
core_1.debug(`matched ${candidate.version}`);
1020+
match = candidate;
1021+
break;
1022+
}
1023+
}
1024+
}
1025+
if (match && file) {
1026+
// clone since we're mutating the file list to be only the file that matches
1027+
result = Object.assign({}, match);
1028+
result.files = [file];
1029+
}
1030+
return result;
1031+
});
1032+
}
1033+
exports._findMatch = _findMatch;
1034+
function _getOsVersion() {
1035+
// TODO: add windows and other linux, arm variants
1036+
// right now filtering on version is only an ubuntu and macos scenario for tools we build for hosted (python)
1037+
const plat = os.platform();
1038+
let version = '';
1039+
if (plat === 'darwin') {
1040+
version = cp.execSync('sw_vers -productVersion').toString();
1041+
}
1042+
else if (plat === 'linux') {
1043+
// lsb_release process not in some containers, readfile
1044+
// Run cat /etc/lsb-release
1045+
// DISTRIB_ID=Ubuntu
1046+
// DISTRIB_RELEASE=18.04
1047+
// DISTRIB_CODENAME=bionic
1048+
// DISTRIB_DESCRIPTION="Ubuntu 18.04.4 LTS"
1049+
const lsbContents = module.exports._readLinuxVersionFile();
1050+
if (lsbContents) {
1051+
const lines = lsbContents.split('\n');
1052+
for (const line of lines) {
1053+
const parts = line.split('=');
1054+
if (parts.length === 2 && parts[0].trim() === 'DISTRIB_RELEASE') {
1055+
version = parts[1].trim();
1056+
break;
1057+
}
1058+
}
1059+
}
1060+
}
1061+
return version;
1062+
}
1063+
exports._getOsVersion = _getOsVersion;
1064+
function _readLinuxVersionFile() {
1065+
const lsbFile = '/etc/lsb-release';
1066+
let contents = '';
1067+
if (fs.existsSync(lsbFile)) {
1068+
contents = fs.readFileSync(lsbFile).toString();
1069+
}
1070+
return contents;
1071+
}
1072+
exports._readLinuxVersionFile = _readLinuxVersionFile;
1073+
//# sourceMappingURL=manifest.js.map
1074+
1075+
/***/ }),
1076+
9581077
/***/ 87:
9591078
/***/ (function(module) {
9601079

@@ -3244,6 +3363,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
32443363
const core = __importStar(__webpack_require__(470));
32453364
const io = __importStar(__webpack_require__(1));
32463365
const fs = __importStar(__webpack_require__(747));
3366+
const mm = __importStar(__webpack_require__(31));
32473367
const os = __importStar(__webpack_require__(87));
32483368
const path = __importStar(__webpack_require__(622));
32493369
const httpm = __importStar(__webpack_require__(539));
@@ -3269,9 +3389,10 @@ const userAgent = 'actions/tool-cache';
32693389
*
32703390
* @param url url of tool to download
32713391
* @param dest path to download tool
3392+
* @param auth authorization header
32723393
* @returns path to downloaded tool
32733394
*/
3274-
function downloadTool(url, dest) {
3395+
function downloadTool(url, dest, auth) {
32753396
return __awaiter(this, void 0, void 0, function* () {
32763397
dest = dest || path.join(_getTempDirectory(), v4_1.default());
32773398
yield io.mkdirP(path.dirname(dest));
@@ -3282,7 +3403,7 @@ function downloadTool(url, dest) {
32823403
const maxSeconds = _getGlobal('TEST_DOWNLOAD_TOOL_RETRY_MAX_SECONDS', 20);
32833404
const retryHelper = new retry_helper_1.RetryHelper(maxAttempts, minSeconds, maxSeconds);
32843405
return yield retryHelper.execute(() => __awaiter(this, void 0, void 0, function* () {
3285-
return yield downloadToolAttempt(url, dest || '');
3406+
return yield downloadToolAttempt(url, dest || '', auth);
32863407
}), (err) => {
32873408
if (err instanceof HTTPError && err.httpStatusCode) {
32883409
// Don't retry anything less than 500, except 408 Request Timeout and 429 Too Many Requests
@@ -3298,7 +3419,7 @@ function downloadTool(url, dest) {
32983419
});
32993420
}
33003421
exports.downloadTool = downloadTool;
3301-
function downloadToolAttempt(url, dest) {
3422+
function downloadToolAttempt(url, dest, auth) {
33023423
return __awaiter(this, void 0, void 0, function* () {
33033424
if (fs.existsSync(dest)) {
33043425
throw new Error(`Destination file path ${dest} already exists`);
@@ -3307,7 +3428,14 @@ function downloadToolAttempt(url, dest) {
33073428
const http = new httpm.HttpClient(userAgent, [], {
33083429
allowRetries: false
33093430
});
3310-
const response = yield http.get(url);
3431+
let headers;
3432+
if (auth) {
3433+
core.debug('set auth');
3434+
headers = {
3435+
authorization: auth
3436+
};
3437+
}
3438+
const response = yield http.get(url, headers);
33113439
if (response.message.statusCode !== 200) {
33123440
const err = new HTTPError(response.message.statusCode);
33133441
core.debug(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`);
@@ -3441,7 +3569,13 @@ function extractTar(file, dest, flags = 'xz') {
34413569
core.debug(versionOutput.trim());
34423570
const isGnuTar = versionOutput.toUpperCase().includes('GNU TAR');
34433571
// Initialize args
3444-
const args = [flags];
3572+
let args;
3573+
if (flags instanceof Array) {
3574+
args = flags;
3575+
}
3576+
else {
3577+
args = [flags];
3578+
}
34453579
if (core.isDebug() && !flags.includes('v')) {
34463580
args.push('-v');
34473581
}
@@ -3643,6 +3777,51 @@ function findAllVersions(toolName, arch) {
36433777
return versions;
36443778
}
36453779
exports.findAllVersions = findAllVersions;
3780+
function getManifestFromRepo(owner, repo, auth, branch = 'master') {
3781+
return __awaiter(this, void 0, void 0, function* () {
3782+
let releases = [];
3783+
const treeUrl = `https://api.github.com/repos/${owner}/${repo}/git/trees/${branch}`;
3784+
const http = new httpm.HttpClient('tool-cache');
3785+
const headers = {};
3786+
if (auth) {
3787+
core.debug('set auth');
3788+
headers.authorization = auth;
3789+
}
3790+
const response = yield http.getJson(treeUrl, headers);
3791+
if (!response.result) {
3792+
return releases;
3793+
}
3794+
let manifestUrl = '';
3795+
for (const item of response.result.tree) {
3796+
if (item.path === 'versions-manifest.json') {
3797+
manifestUrl = item.url;
3798+
break;
3799+
}
3800+
}
3801+
headers['accept'] = 'application/vnd.github.VERSION.raw';
3802+
let versionsRaw = yield (yield http.get(manifestUrl, headers)).readBody();
3803+
if (versionsRaw) {
3804+
// shouldn't be needed but protects against invalid json saved with BOM
3805+
versionsRaw = versionsRaw.replace(/^\uFEFF/, '');
3806+
try {
3807+
releases = JSON.parse(versionsRaw);
3808+
}
3809+
catch (_a) {
3810+
core.debug('Invalid json');
3811+
}
3812+
}
3813+
return releases;
3814+
});
3815+
}
3816+
exports.getManifestFromRepo = getManifestFromRepo;
3817+
function findFromManifest(versionSpec, stable, manifest, archFilter = os.arch()) {
3818+
return __awaiter(this, void 0, void 0, function* () {
3819+
// wrap the internal impl
3820+
const match = yield mm._findMatch(versionSpec, stable, manifest, archFilter);
3821+
return match;
3822+
});
3823+
}
3824+
exports.findFromManifest = findFromManifest;
36463825
function _createExtractFolder(dest) {
36473826
return __awaiter(this, void 0, void 0, function* () {
36483827
if (!dest) {

0 commit comments

Comments
 (0)