@@ -4694,6 +4694,7 @@ const installer = __importStar(__webpack_require__(749));
4694
4694
const auth = __importStar(__webpack_require__(202));
4695
4695
const path = __importStar(__webpack_require__(622));
4696
4696
const url_1 = __webpack_require__(835);
4697
+ const os = __webpack_require__(87);
4697
4698
function run() {
4698
4699
return __awaiter(this, void 0, void 0, function* () {
4699
4700
try {
@@ -4705,12 +4706,21 @@ function run() {
4705
4706
if (!version) {
4706
4707
version = core.getInput('version');
4707
4708
}
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
+ }
4708
4718
if (version) {
4709
4719
let token = core.getInput('token');
4710
4720
let auth = !token || isGhes() ? undefined : `token ${token}`;
4711
4721
let stable = (core.getInput('stable') || 'true').toUpperCase() === 'TRUE';
4712
4722
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 );
4714
4724
}
4715
4725
const registryUrl = core.getInput('registry-url');
4716
4726
const alwaysAuth = core.getInput('always-auth');
@@ -13093,13 +13103,13 @@ const tc = __importStar(__webpack_require__(533));
13093
13103
const path = __importStar(__webpack_require__(622));
13094
13104
const semver = __importStar(__webpack_require__(280));
13095
13105
const fs = __webpack_require__(747);
13096
- function getNode(versionSpec, stable, checkLatest, auth) {
13106
+ function getNode(versionSpec, stable, checkLatest, auth, arch = os.arch() ) {
13097
13107
return __awaiter(this, void 0, void 0, function* () {
13098
13108
let osPlat = os.platform();
13099
- let osArch = translateArchToDistUrl(os. arch() );
13109
+ let osArch = translateArchToDistUrl(arch);
13100
13110
if (checkLatest) {
13101
13111
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 );
13103
13113
if (resolvedVersion) {
13104
13114
versionSpec = resolvedVersion;
13105
13115
core.info(`Resolved as '${versionSpec}'`);
@@ -13110,7 +13120,7 @@ function getNode(versionSpec, stable, checkLatest, auth) {
13110
13120
}
13111
13121
// check cache
13112
13122
let toolPath;
13113
- toolPath = tc.find('node', versionSpec);
13123
+ toolPath = tc.find('node', versionSpec, osArch );
13114
13124
// If not found in cache, download
13115
13125
if (toolPath) {
13116
13126
core.info(`Found in cache @ ${toolPath}`);
@@ -13123,9 +13133,9 @@ function getNode(versionSpec, stable, checkLatest, auth) {
13123
13133
// Try download from internal distribution (popular versions only)
13124
13134
//
13125
13135
try {
13126
- info = yield getInfoFromManifest(versionSpec, stable, auth);
13136
+ info = yield getInfoFromManifest(versionSpec, stable, auth, osArch );
13127
13137
if (info) {
13128
- core.info(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`);
13138
+ core.info(`Acquiring ${info.resolvedVersion} - ${info.arch} from ${info.downloadUrl}`);
13129
13139
downloadPath = yield tc.downloadTool(info.downloadUrl, undefined, auth);
13130
13140
}
13131
13141
else {
@@ -13148,17 +13158,17 @@ function getNode(versionSpec, stable, checkLatest, auth) {
13148
13158
// Download from nodejs.org
13149
13159
//
13150
13160
if (!downloadPath) {
13151
- info = yield getInfoFromDist(versionSpec);
13161
+ info = yield getInfoFromDist(versionSpec, arch );
13152
13162
if (!info) {
13153
13163
throw new Error(`Unable to find Node version '${versionSpec}' for platform ${osPlat} and architecture ${osArch}.`);
13154
13164
}
13155
- core.info(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`);
13165
+ core.info(`Acquiring ${info.resolvedVersion} - ${info.arch} from ${info.downloadUrl}`);
13156
13166
try {
13157
13167
downloadPath = yield tc.downloadTool(info.downloadUrl);
13158
13168
}
13159
13169
catch (err) {
13160
13170
if (err instanceof tc.HTTPError && err.httpStatusCode == 404) {
13161
- return yield acquireNodeFromFallbackLocation(info.resolvedVersion);
13171
+ return yield acquireNodeFromFallbackLocation(info.resolvedVersion, info.arch );
13162
13172
}
13163
13173
throw err;
13164
13174
}
@@ -13189,7 +13199,7 @@ function getNode(versionSpec, stable, checkLatest, auth) {
13189
13199
// Install into the local tool cache - node extracts with a root folder that matches the fileName downloaded
13190
13200
//
13191
13201
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 );
13193
13203
core.info('Done');
13194
13204
}
13195
13205
//
@@ -13206,26 +13216,27 @@ function getNode(versionSpec, stable, checkLatest, auth) {
13206
13216
});
13207
13217
}
13208
13218
exports.getNode = getNode;
13209
- function getInfoFromManifest(versionSpec, stable, auth) {
13219
+ function getInfoFromManifest(versionSpec, stable, auth, osArch = translateArchToDistUrl(os.arch()) ) {
13210
13220
return __awaiter(this, void 0, void 0, function* () {
13211
13221
let info = null;
13212
13222
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 );
13214
13224
if (rel && rel.files.length > 0) {
13215
13225
info = {};
13216
13226
info.resolvedVersion = rel.version;
13227
+ info.arch = rel.files[0].arch;
13217
13228
info.downloadUrl = rel.files[0].download_url;
13218
13229
info.fileName = rel.files[0].filename;
13219
13230
}
13220
13231
return info;
13221
13232
});
13222
13233
}
13223
- function getInfoFromDist(versionSpec) {
13234
+ function getInfoFromDist(versionSpec, arch = os.arch() ) {
13224
13235
return __awaiter(this, void 0, void 0, function* () {
13225
13236
let osPlat = os.platform();
13226
- let osArch = translateArchToDistUrl(os. arch() );
13237
+ let osArch = translateArchToDistUrl(arch);
13227
13238
let version;
13228
- version = yield queryDistForMatch(versionSpec);
13239
+ version = yield queryDistForMatch(versionSpec, arch );
13229
13240
if (!version) {
13230
13241
return null;
13231
13242
}
@@ -13241,14 +13252,15 @@ function getInfoFromDist(versionSpec) {
13241
13252
return {
13242
13253
downloadUrl: url,
13243
13254
resolvedVersion: version,
13255
+ arch: arch,
13244
13256
fileName: fileName
13245
13257
};
13246
13258
});
13247
13259
}
13248
- function resolveVersionFromManifest(versionSpec, stable, auth) {
13260
+ function resolveVersionFromManifest(versionSpec, stable, auth, osArch = translateArchToDistUrl(os.arch()) ) {
13249
13261
return __awaiter(this, void 0, void 0, function* () {
13250
13262
try {
13251
- const info = yield getInfoFromManifest(versionSpec, stable, auth);
13263
+ const info = yield getInfoFromManifest(versionSpec, stable, auth, osArch );
13252
13264
return info === null || info === void 0 ? void 0 : info.resolvedVersion;
13253
13265
}
13254
13266
catch (err) {
@@ -13283,10 +13295,10 @@ function evaluateVersions(versions, versionSpec) {
13283
13295
}
13284
13296
return version;
13285
13297
}
13286
- function queryDistForMatch(versionSpec) {
13298
+ function queryDistForMatch(versionSpec, arch = os.arch() ) {
13287
13299
return __awaiter(this, void 0, void 0, function* () {
13288
13300
let osPlat = os.platform();
13289
- let osArch = translateArchToDistUrl(os. arch() );
13301
+ let osArch = translateArchToDistUrl(arch);
13290
13302
// node offers a json list of versions
13291
13303
let dataFileName;
13292
13304
switch (osPlat) {
@@ -13339,10 +13351,10 @@ exports.getVersionsFromDist = getVersionsFromDist;
13339
13351
// This method attempts to download and cache the resources from these alternative locations.
13340
13352
// Note also that the files are normally zipped but in this case they are just an exe
13341
13353
// and lib file in a folder, not zipped.
13342
- function acquireNodeFromFallbackLocation(version) {
13354
+ function acquireNodeFromFallbackLocation(version, arch = os.arch() ) {
13343
13355
return __awaiter(this, void 0, void 0, function* () {
13344
13356
let osPlat = os.platform();
13345
- let osArch = translateArchToDistUrl(os. arch() );
13357
+ let osArch = translateArchToDistUrl(arch);
13346
13358
// Create temporary folder to download in to
13347
13359
const tempDownloadFolder = 'temp_' + Math.floor(Math.random() * 2000000000);
13348
13360
const tempDirectory = process.env['RUNNER_TEMP'] || '';
@@ -13373,7 +13385,7 @@ function acquireNodeFromFallbackLocation(version) {
13373
13385
throw err;
13374
13386
}
13375
13387
}
13376
- let toolPath = yield tc.cacheDir(tempDir, 'node', version);
13388
+ let toolPath = yield tc.cacheDir(tempDir, 'node', version, arch );
13377
13389
core.addPath(toolPath);
13378
13390
return toolPath;
13379
13391
});
0 commit comments