@@ -4694,6 +4694,7 @@ const installer = __importStar(__webpack_require__(749));
46944694const auth = __importStar(__webpack_require__(202));
46954695const path = __importStar(__webpack_require__(622));
46964696const url_1 = __webpack_require__(835);
4697+ const os = __webpack_require__(87);
46974698function run() {
46984699 return __awaiter(this, void 0, void 0, function* () {
46994700 try {
@@ -4705,12 +4706,21 @@ function run() {
47054706 if (!version) {
47064707 version = core.getInput('version');
47074708 }
4709+ let arch = core.getInput('architecture');
4710+ // if architecture supplied but node-version is not
4711+ // if we don't throw a warning, the already installed x64 node will be used which is not probably what user meant.
4712+ if (arch && !version) {
4713+ core.warning('`architecture` is provided but `node-version` is missing. In this configuration, the version/architecture of Node will not be changed. To fix this, provide `architecture` in combination with `node-version`');
4714+ }
4715+ if (!arch) {
4716+ arch = os.arch();
4717+ }
47084718 if (version) {
47094719 let token = core.getInput('token');
47104720 let auth = !token || isGhes() ? undefined : `token ${token}`;
47114721 let stable = (core.getInput('stable') || 'true').toUpperCase() === 'TRUE';
47124722 const checkLatest = (core.getInput('check-latest') || 'false').toUpperCase() === 'TRUE';
4713- yield installer.getNode(version, stable, checkLatest, auth);
4723+ yield installer.getNode(version, stable, checkLatest, auth, arch );
47144724 }
47154725 const registryUrl = core.getInput('registry-url');
47164726 const alwaysAuth = core.getInput('always-auth');
@@ -13093,13 +13103,13 @@ const tc = __importStar(__webpack_require__(533));
1309313103const path = __importStar(__webpack_require__(622));
1309413104const semver = __importStar(__webpack_require__(280));
1309513105const fs = __webpack_require__(747);
13096- function getNode(versionSpec, stable, checkLatest, auth) {
13106+ function getNode(versionSpec, stable, checkLatest, auth, arch = os.arch() ) {
1309713107 return __awaiter(this, void 0, void 0, function* () {
1309813108 let osPlat = os.platform();
13099- let osArch = translateArchToDistUrl(os. arch() );
13109+ let osArch = translateArchToDistUrl(arch);
1310013110 if (checkLatest) {
1310113111 core.info('Attempt to resolve the latest version from manifest...');
13102- const resolvedVersion = yield resolveVersionFromManifest(versionSpec, stable, auth);
13112+ const resolvedVersion = yield resolveVersionFromManifest(versionSpec, stable, auth, osArch );
1310313113 if (resolvedVersion) {
1310413114 versionSpec = resolvedVersion;
1310513115 core.info(`Resolved as '${versionSpec}'`);
@@ -13110,7 +13120,7 @@ function getNode(versionSpec, stable, checkLatest, auth) {
1311013120 }
1311113121 // check cache
1311213122 let toolPath;
13113- toolPath = tc.find('node', versionSpec);
13123+ toolPath = tc.find('node', versionSpec, osArch );
1311413124 // If not found in cache, download
1311513125 if (toolPath) {
1311613126 core.info(`Found in cache @ ${toolPath}`);
@@ -13123,9 +13133,9 @@ function getNode(versionSpec, stable, checkLatest, auth) {
1312313133 // Try download from internal distribution (popular versions only)
1312413134 //
1312513135 try {
13126- info = yield getInfoFromManifest(versionSpec, stable, auth);
13136+ info = yield getInfoFromManifest(versionSpec, stable, auth, osArch );
1312713137 if (info) {
13128- core.info(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`);
13138+ core.info(`Acquiring ${info.resolvedVersion} - ${info.arch} from ${info.downloadUrl}`);
1312913139 downloadPath = yield tc.downloadTool(info.downloadUrl, undefined, auth);
1313013140 }
1313113141 else {
@@ -13148,17 +13158,17 @@ function getNode(versionSpec, stable, checkLatest, auth) {
1314813158 // Download from nodejs.org
1314913159 //
1315013160 if (!downloadPath) {
13151- info = yield getInfoFromDist(versionSpec);
13161+ info = yield getInfoFromDist(versionSpec, arch );
1315213162 if (!info) {
1315313163 throw new Error(`Unable to find Node version '${versionSpec}' for platform ${osPlat} and architecture ${osArch}.`);
1315413164 }
13155- core.info(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`);
13165+ core.info(`Acquiring ${info.resolvedVersion} - ${info.arch} from ${info.downloadUrl}`);
1315613166 try {
1315713167 downloadPath = yield tc.downloadTool(info.downloadUrl);
1315813168 }
1315913169 catch (err) {
1316013170 if (err instanceof tc.HTTPError && err.httpStatusCode == 404) {
13161- return yield acquireNodeFromFallbackLocation(info.resolvedVersion);
13171+ return yield acquireNodeFromFallbackLocation(info.resolvedVersion, info.arch );
1316213172 }
1316313173 throw err;
1316413174 }
@@ -13189,7 +13199,7 @@ function getNode(versionSpec, stable, checkLatest, auth) {
1318913199 // Install into the local tool cache - node extracts with a root folder that matches the fileName downloaded
1319013200 //
1319113201 core.info('Adding to the cache ...');
13192- toolPath = yield tc.cacheDir(extPath, 'node', info.resolvedVersion);
13202+ toolPath = yield tc.cacheDir(extPath, 'node', info.resolvedVersion, info.arch );
1319313203 core.info('Done');
1319413204 }
1319513205 //
@@ -13206,26 +13216,27 @@ function getNode(versionSpec, stable, checkLatest, auth) {
1320613216 });
1320713217}
1320813218exports.getNode = getNode;
13209- function getInfoFromManifest(versionSpec, stable, auth) {
13219+ function getInfoFromManifest(versionSpec, stable, auth, osArch = translateArchToDistUrl(os.arch()) ) {
1321013220 return __awaiter(this, void 0, void 0, function* () {
1321113221 let info = null;
1321213222 const releases = yield tc.getManifestFromRepo('actions', 'node-versions', auth, 'main');
13213- const rel = yield tc.findFromManifest(versionSpec, stable, releases);
13223+ const rel = yield tc.findFromManifest(versionSpec, stable, releases, osArch );
1321413224 if (rel && rel.files.length > 0) {
1321513225 info = {};
1321613226 info.resolvedVersion = rel.version;
13227+ info.arch = rel.files[0].arch;
1321713228 info.downloadUrl = rel.files[0].download_url;
1321813229 info.fileName = rel.files[0].filename;
1321913230 }
1322013231 return info;
1322113232 });
1322213233}
13223- function getInfoFromDist(versionSpec) {
13234+ function getInfoFromDist(versionSpec, arch = os.arch() ) {
1322413235 return __awaiter(this, void 0, void 0, function* () {
1322513236 let osPlat = os.platform();
13226- let osArch = translateArchToDistUrl(os. arch() );
13237+ let osArch = translateArchToDistUrl(arch);
1322713238 let version;
13228- version = yield queryDistForMatch(versionSpec);
13239+ version = yield queryDistForMatch(versionSpec, arch );
1322913240 if (!version) {
1323013241 return null;
1323113242 }
@@ -13241,14 +13252,15 @@ function getInfoFromDist(versionSpec) {
1324113252 return {
1324213253 downloadUrl: url,
1324313254 resolvedVersion: version,
13255+ arch: arch,
1324413256 fileName: fileName
1324513257 };
1324613258 });
1324713259}
13248- function resolveVersionFromManifest(versionSpec, stable, auth) {
13260+ function resolveVersionFromManifest(versionSpec, stable, auth, osArch = translateArchToDistUrl(os.arch()) ) {
1324913261 return __awaiter(this, void 0, void 0, function* () {
1325013262 try {
13251- const info = yield getInfoFromManifest(versionSpec, stable, auth);
13263+ const info = yield getInfoFromManifest(versionSpec, stable, auth, osArch );
1325213264 return info === null || info === void 0 ? void 0 : info.resolvedVersion;
1325313265 }
1325413266 catch (err) {
@@ -13283,10 +13295,10 @@ function evaluateVersions(versions, versionSpec) {
1328313295 }
1328413296 return version;
1328513297}
13286- function queryDistForMatch(versionSpec) {
13298+ function queryDistForMatch(versionSpec, arch = os.arch() ) {
1328713299 return __awaiter(this, void 0, void 0, function* () {
1328813300 let osPlat = os.platform();
13289- let osArch = translateArchToDistUrl(os. arch() );
13301+ let osArch = translateArchToDistUrl(arch);
1329013302 // node offers a json list of versions
1329113303 let dataFileName;
1329213304 switch (osPlat) {
@@ -13339,10 +13351,10 @@ exports.getVersionsFromDist = getVersionsFromDist;
1333913351// This method attempts to download and cache the resources from these alternative locations.
1334013352// Note also that the files are normally zipped but in this case they are just an exe
1334113353// and lib file in a folder, not zipped.
13342- function acquireNodeFromFallbackLocation(version) {
13354+ function acquireNodeFromFallbackLocation(version, arch = os.arch() ) {
1334313355 return __awaiter(this, void 0, void 0, function* () {
1334413356 let osPlat = os.platform();
13345- let osArch = translateArchToDistUrl(os. arch() );
13357+ let osArch = translateArchToDistUrl(arch);
1334613358 // Create temporary folder to download in to
1334713359 const tempDownloadFolder = 'temp_' + Math.floor(Math.random() * 2000000000);
1334813360 const tempDirectory = process.env['RUNNER_TEMP'] || '';
@@ -13373,7 +13385,7 @@ function acquireNodeFromFallbackLocation(version) {
1337313385 throw err;
1337413386 }
1337513387 }
13376- let toolPath = yield tc.cacheDir(tempDir, 'node', version);
13388+ let toolPath = yield tc.cacheDir(tempDir, 'node', version, arch );
1337713389 core.addPath(toolPath);
1337813390 return toolPath;
1337913391 });
0 commit comments