Skip to content

Commit 2801f51

Browse files
committed
chore: build
git clean -ffdx && npm ci && npm run pre-checkin
1 parent 0a161fe commit 2801f51

File tree

1 file changed

+30
-23
lines changed

1 file changed

+30
-23
lines changed

dist/index.js

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4632,6 +4632,7 @@ const installer = __importStar(__webpack_require__(749));
46324632
const auth = __importStar(__webpack_require__(202));
46334633
const path = __importStar(__webpack_require__(622));
46344634
const url_1 = __webpack_require__(835);
4635+
const os = __webpack_require__(87);
46354636
function run() {
46364637
return __awaiter(this, void 0, void 0, function* () {
46374638
try {
@@ -4643,12 +4644,16 @@ function run() {
46434644
if (!version) {
46444645
version = core.getInput('version');
46454646
}
4647+
let arch = core.getInput('node-arch');
4648+
if (!arch) {
4649+
arch = os.arch();
4650+
}
46464651
if (version) {
46474652
let token = core.getInput('token');
46484653
let auth = !token || isGhes() ? undefined : `token ${token}`;
46494654
let stable = (core.getInput('stable') || 'true').toUpperCase() === 'TRUE';
46504655
const checkLatest = (core.getInput('check-latest') || 'false').toUpperCase() === 'TRUE';
4651-
yield installer.getNode(version, stable, checkLatest, auth);
4656+
yield installer.getNode(version, stable, checkLatest, auth, arch);
46524657
}
46534658
const registryUrl = core.getInput('registry-url');
46544659
const alwaysAuth = core.getInput('always-auth');
@@ -12994,13 +12999,13 @@ const tc = __importStar(__webpack_require__(533));
1299412999
const path = __importStar(__webpack_require__(622));
1299513000
const semver = __importStar(__webpack_require__(280));
1299613001
const fs = __webpack_require__(747);
12997-
function getNode(versionSpec, stable, checkLatest, auth) {
13002+
function getNode(versionSpec, stable, checkLatest, auth, arch = os.arch()) {
1299813003
return __awaiter(this, void 0, void 0, function* () {
1299913004
let osPlat = os.platform();
13000-
let osArch = translateArchToDistUrl(os.arch());
13005+
let osArch = translateArchToDistUrl(arch);
1300113006
if (checkLatest) {
1300213007
core.info('Attempt to resolve the latest version from manifest...');
13003-
const resolvedVersion = yield resolveVersionFromManifest(versionSpec, stable, auth);
13008+
const resolvedVersion = yield resolveVersionFromManifest(versionSpec, stable, auth, osArch);
1300413009
if (resolvedVersion) {
1300513010
versionSpec = resolvedVersion;
1300613011
core.info(`Resolved as '${versionSpec}'`);
@@ -13011,7 +13016,7 @@ function getNode(versionSpec, stable, checkLatest, auth) {
1301113016
}
1301213017
// check cache
1301313018
let toolPath;
13014-
toolPath = tc.find('node', versionSpec);
13019+
toolPath = tc.find('node', versionSpec, osArch);
1301513020
// If not found in cache, download
1301613021
if (toolPath) {
1301713022
core.info(`Found in cache @ ${toolPath}`);
@@ -13024,9 +13029,9 @@ function getNode(versionSpec, stable, checkLatest, auth) {
1302413029
// Try download from internal distribution (popular versions only)
1302513030
//
1302613031
try {
13027-
info = yield getInfoFromManifest(versionSpec, stable, auth);
13032+
info = yield getInfoFromManifest(versionSpec, stable, auth, osArch);
1302813033
if (info) {
13029-
core.info(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`);
13034+
core.info(`Acquiring ${info.resolvedVersion} - ${info.arch} from ${info.downloadUrl}`);
1303013035
downloadPath = yield tc.downloadTool(info.downloadUrl, undefined, auth);
1303113036
}
1303213037
else {
@@ -13049,17 +13054,17 @@ function getNode(versionSpec, stable, checkLatest, auth) {
1304913054
// Download from nodejs.org
1305013055
//
1305113056
if (!downloadPath) {
13052-
info = yield getInfoFromDist(versionSpec);
13057+
info = yield getInfoFromDist(versionSpec, arch);
1305313058
if (!info) {
1305413059
throw new Error(`Unable to find Node version '${versionSpec}' for platform ${osPlat} and architecture ${osArch}.`);
1305513060
}
13056-
core.info(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`);
13061+
core.info(`Acquiring ${info.resolvedVersion} - ${info.arch} from ${info.downloadUrl}`);
1305713062
try {
1305813063
downloadPath = yield tc.downloadTool(info.downloadUrl);
1305913064
}
1306013065
catch (err) {
1306113066
if (err instanceof tc.HTTPError && err.httpStatusCode == 404) {
13062-
return yield acquireNodeFromFallbackLocation(info.resolvedVersion);
13067+
return yield acquireNodeFromFallbackLocation(info.resolvedVersion, info.arch);
1306313068
}
1306413069
throw err;
1306513070
}
@@ -13090,7 +13095,7 @@ function getNode(versionSpec, stable, checkLatest, auth) {
1309013095
// Install into the local tool cache - node extracts with a root folder that matches the fileName downloaded
1309113096
//
1309213097
core.info('Adding to the cache ...');
13093-
toolPath = yield tc.cacheDir(extPath, 'node', info.resolvedVersion);
13098+
toolPath = yield tc.cacheDir(extPath, 'node', info.resolvedVersion, info.arch);
1309413099
core.info('Done');
1309513100
}
1309613101
//
@@ -13107,26 +13112,27 @@ function getNode(versionSpec, stable, checkLatest, auth) {
1310713112
});
1310813113
}
1310913114
exports.getNode = getNode;
13110-
function getInfoFromManifest(versionSpec, stable, auth) {
13115+
function getInfoFromManifest(versionSpec, stable, auth, osArch = translateArchToDistUrl(os.arch())) {
1311113116
return __awaiter(this, void 0, void 0, function* () {
1311213117
let info = null;
1311313118
const releases = yield tc.getManifestFromRepo('actions', 'node-versions', auth, 'main');
13114-
const rel = yield tc.findFromManifest(versionSpec, stable, releases);
13119+
const rel = yield tc.findFromManifest(versionSpec, stable, releases, osArch);
1311513120
if (rel && rel.files.length > 0) {
1311613121
info = {};
1311713122
info.resolvedVersion = rel.version;
13123+
info.arch = rel.files[0].arch;
1311813124
info.downloadUrl = rel.files[0].download_url;
1311913125
info.fileName = rel.files[0].filename;
1312013126
}
1312113127
return info;
1312213128
});
1312313129
}
13124-
function getInfoFromDist(versionSpec) {
13130+
function getInfoFromDist(versionSpec, arch = os.arch()) {
1312513131
return __awaiter(this, void 0, void 0, function* () {
1312613132
let osPlat = os.platform();
13127-
let osArch = translateArchToDistUrl(os.arch());
13133+
let osArch = translateArchToDistUrl(arch);
1312813134
let version;
13129-
version = yield queryDistForMatch(versionSpec);
13135+
version = yield queryDistForMatch(versionSpec, arch);
1313013136
if (!version) {
1313113137
return null;
1313213138
}
@@ -13142,14 +13148,15 @@ function getInfoFromDist(versionSpec) {
1314213148
return {
1314313149
downloadUrl: url,
1314413150
resolvedVersion: version,
13151+
arch: arch,
1314513152
fileName: fileName
1314613153
};
1314713154
});
1314813155
}
13149-
function resolveVersionFromManifest(versionSpec, stable, auth) {
13156+
function resolveVersionFromManifest(versionSpec, stable, auth, osArch = translateArchToDistUrl(os.arch())) {
1315013157
return __awaiter(this, void 0, void 0, function* () {
1315113158
try {
13152-
const info = yield getInfoFromManifest(versionSpec, stable, auth);
13159+
const info = yield getInfoFromManifest(versionSpec, stable, auth, osArch);
1315313160
return info === null || info === void 0 ? void 0 : info.resolvedVersion;
1315413161
}
1315513162
catch (err) {
@@ -13184,10 +13191,10 @@ function evaluateVersions(versions, versionSpec) {
1318413191
}
1318513192
return version;
1318613193
}
13187-
function queryDistForMatch(versionSpec) {
13194+
function queryDistForMatch(versionSpec, arch = os.arch()) {
1318813195
return __awaiter(this, void 0, void 0, function* () {
1318913196
let osPlat = os.platform();
13190-
let osArch = translateArchToDistUrl(os.arch());
13197+
let osArch = translateArchToDistUrl(arch);
1319113198
// node offers a json list of versions
1319213199
let dataFileName;
1319313200
switch (osPlat) {
@@ -13240,10 +13247,10 @@ exports.getVersionsFromDist = getVersionsFromDist;
1324013247
// This method attempts to download and cache the resources from these alternative locations.
1324113248
// Note also that the files are normally zipped but in this case they are just an exe
1324213249
// and lib file in a folder, not zipped.
13243-
function acquireNodeFromFallbackLocation(version) {
13250+
function acquireNodeFromFallbackLocation(version, arch = os.arch()) {
1324413251
return __awaiter(this, void 0, void 0, function* () {
1324513252
let osPlat = os.platform();
13246-
let osArch = translateArchToDistUrl(os.arch());
13253+
let osArch = translateArchToDistUrl(arch);
1324713254
// Create temporary folder to download in to
1324813255
const tempDownloadFolder = 'temp_' + Math.floor(Math.random() * 2000000000);
1324913256
const tempDirectory = process.env['RUNNER_TEMP'] || '';
@@ -13274,7 +13281,7 @@ function acquireNodeFromFallbackLocation(version) {
1327413281
throw err;
1327513282
}
1327613283
}
13277-
let toolPath = yield tc.cacheDir(tempDir, 'node', version);
13284+
let toolPath = yield tc.cacheDir(tempDir, 'node', version, arch);
1327813285
core.addPath(toolPath);
1327913286
return toolPath;
1328013287
});

0 commit comments

Comments
 (0)