@@ -4632,6 +4632,7 @@ const installer = __importStar(__webpack_require__(749));
4632
4632
const auth = __importStar(__webpack_require__(202));
4633
4633
const path = __importStar(__webpack_require__(622));
4634
4634
const url_1 = __webpack_require__(835);
4635
+ const os = __webpack_require__(87);
4635
4636
function run() {
4636
4637
return __awaiter(this, void 0, void 0, function* () {
4637
4638
try {
@@ -4643,12 +4644,16 @@ function run() {
4643
4644
if (!version) {
4644
4645
version = core.getInput('version');
4645
4646
}
4647
+ let arch = core.getInput('node-arch');
4648
+ if (!arch) {
4649
+ arch = os.arch();
4650
+ }
4646
4651
if (version) {
4647
4652
let token = core.getInput('token');
4648
4653
let auth = !token || isGhes() ? undefined : `token ${token}`;
4649
4654
let stable = (core.getInput('stable') || 'true').toUpperCase() === 'TRUE';
4650
4655
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 );
4652
4657
}
4653
4658
const registryUrl = core.getInput('registry-url');
4654
4659
const alwaysAuth = core.getInput('always-auth');
@@ -12994,13 +12999,13 @@ const tc = __importStar(__webpack_require__(533));
12994
12999
const path = __importStar(__webpack_require__(622));
12995
13000
const semver = __importStar(__webpack_require__(280));
12996
13001
const fs = __webpack_require__(747);
12997
- function getNode(versionSpec, stable, checkLatest, auth) {
13002
+ function getNode(versionSpec, stable, checkLatest, auth, arch = os.arch() ) {
12998
13003
return __awaiter(this, void 0, void 0, function* () {
12999
13004
let osPlat = os.platform();
13000
- let osArch = translateArchToDistUrl(os. arch() );
13005
+ let osArch = translateArchToDistUrl(arch);
13001
13006
if (checkLatest) {
13002
13007
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 );
13004
13009
if (resolvedVersion) {
13005
13010
versionSpec = resolvedVersion;
13006
13011
core.info(`Resolved as '${versionSpec}'`);
@@ -13011,7 +13016,7 @@ function getNode(versionSpec, stable, checkLatest, auth) {
13011
13016
}
13012
13017
// check cache
13013
13018
let toolPath;
13014
- toolPath = tc.find('node', versionSpec);
13019
+ toolPath = tc.find('node', versionSpec, osArch );
13015
13020
// If not found in cache, download
13016
13021
if (toolPath) {
13017
13022
core.info(`Found in cache @ ${toolPath}`);
@@ -13024,9 +13029,9 @@ function getNode(versionSpec, stable, checkLatest, auth) {
13024
13029
// Try download from internal distribution (popular versions only)
13025
13030
//
13026
13031
try {
13027
- info = yield getInfoFromManifest(versionSpec, stable, auth);
13032
+ info = yield getInfoFromManifest(versionSpec, stable, auth, osArch );
13028
13033
if (info) {
13029
- core.info(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`);
13034
+ core.info(`Acquiring ${info.resolvedVersion} - ${info.arch} from ${info.downloadUrl}`);
13030
13035
downloadPath = yield tc.downloadTool(info.downloadUrl, undefined, auth);
13031
13036
}
13032
13037
else {
@@ -13049,17 +13054,17 @@ function getNode(versionSpec, stable, checkLatest, auth) {
13049
13054
// Download from nodejs.org
13050
13055
//
13051
13056
if (!downloadPath) {
13052
- info = yield getInfoFromDist(versionSpec);
13057
+ info = yield getInfoFromDist(versionSpec, arch );
13053
13058
if (!info) {
13054
13059
throw new Error(`Unable to find Node version '${versionSpec}' for platform ${osPlat} and architecture ${osArch}.`);
13055
13060
}
13056
- core.info(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`);
13061
+ core.info(`Acquiring ${info.resolvedVersion} - ${info.arch} from ${info.downloadUrl}`);
13057
13062
try {
13058
13063
downloadPath = yield tc.downloadTool(info.downloadUrl);
13059
13064
}
13060
13065
catch (err) {
13061
13066
if (err instanceof tc.HTTPError && err.httpStatusCode == 404) {
13062
- return yield acquireNodeFromFallbackLocation(info.resolvedVersion);
13067
+ return yield acquireNodeFromFallbackLocation(info.resolvedVersion, info.arch );
13063
13068
}
13064
13069
throw err;
13065
13070
}
@@ -13090,7 +13095,7 @@ function getNode(versionSpec, stable, checkLatest, auth) {
13090
13095
// Install into the local tool cache - node extracts with a root folder that matches the fileName downloaded
13091
13096
//
13092
13097
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 );
13094
13099
core.info('Done');
13095
13100
}
13096
13101
//
@@ -13107,26 +13112,27 @@ function getNode(versionSpec, stable, checkLatest, auth) {
13107
13112
});
13108
13113
}
13109
13114
exports.getNode = getNode;
13110
- function getInfoFromManifest(versionSpec, stable, auth) {
13115
+ function getInfoFromManifest(versionSpec, stable, auth, osArch = translateArchToDistUrl(os.arch()) ) {
13111
13116
return __awaiter(this, void 0, void 0, function* () {
13112
13117
let info = null;
13113
13118
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 );
13115
13120
if (rel && rel.files.length > 0) {
13116
13121
info = {};
13117
13122
info.resolvedVersion = rel.version;
13123
+ info.arch = rel.files[0].arch;
13118
13124
info.downloadUrl = rel.files[0].download_url;
13119
13125
info.fileName = rel.files[0].filename;
13120
13126
}
13121
13127
return info;
13122
13128
});
13123
13129
}
13124
- function getInfoFromDist(versionSpec) {
13130
+ function getInfoFromDist(versionSpec, arch = os.arch() ) {
13125
13131
return __awaiter(this, void 0, void 0, function* () {
13126
13132
let osPlat = os.platform();
13127
- let osArch = translateArchToDistUrl(os. arch() );
13133
+ let osArch = translateArchToDistUrl(arch);
13128
13134
let version;
13129
- version = yield queryDistForMatch(versionSpec);
13135
+ version = yield queryDistForMatch(versionSpec, arch );
13130
13136
if (!version) {
13131
13137
return null;
13132
13138
}
@@ -13142,14 +13148,15 @@ function getInfoFromDist(versionSpec) {
13142
13148
return {
13143
13149
downloadUrl: url,
13144
13150
resolvedVersion: version,
13151
+ arch: arch,
13145
13152
fileName: fileName
13146
13153
};
13147
13154
});
13148
13155
}
13149
- function resolveVersionFromManifest(versionSpec, stable, auth) {
13156
+ function resolveVersionFromManifest(versionSpec, stable, auth, osArch = translateArchToDistUrl(os.arch()) ) {
13150
13157
return __awaiter(this, void 0, void 0, function* () {
13151
13158
try {
13152
- const info = yield getInfoFromManifest(versionSpec, stable, auth);
13159
+ const info = yield getInfoFromManifest(versionSpec, stable, auth, osArch );
13153
13160
return info === null || info === void 0 ? void 0 : info.resolvedVersion;
13154
13161
}
13155
13162
catch (err) {
@@ -13184,10 +13191,10 @@ function evaluateVersions(versions, versionSpec) {
13184
13191
}
13185
13192
return version;
13186
13193
}
13187
- function queryDistForMatch(versionSpec) {
13194
+ function queryDistForMatch(versionSpec, arch = os.arch() ) {
13188
13195
return __awaiter(this, void 0, void 0, function* () {
13189
13196
let osPlat = os.platform();
13190
- let osArch = translateArchToDistUrl(os. arch() );
13197
+ let osArch = translateArchToDistUrl(arch);
13191
13198
// node offers a json list of versions
13192
13199
let dataFileName;
13193
13200
switch (osPlat) {
@@ -13240,10 +13247,10 @@ exports.getVersionsFromDist = getVersionsFromDist;
13240
13247
// This method attempts to download and cache the resources from these alternative locations.
13241
13248
// Note also that the files are normally zipped but in this case they are just an exe
13242
13249
// and lib file in a folder, not zipped.
13243
- function acquireNodeFromFallbackLocation(version) {
13250
+ function acquireNodeFromFallbackLocation(version, arch = os.arch() ) {
13244
13251
return __awaiter(this, void 0, void 0, function* () {
13245
13252
let osPlat = os.platform();
13246
- let osArch = translateArchToDistUrl(os. arch() );
13253
+ let osArch = translateArchToDistUrl(arch);
13247
13254
// Create temporary folder to download in to
13248
13255
const tempDownloadFolder = 'temp_' + Math.floor(Math.random() * 2000000000);
13249
13256
const tempDirectory = process.env['RUNNER_TEMP'] || '';
@@ -13274,7 +13281,7 @@ function acquireNodeFromFallbackLocation(version) {
13274
13281
throw err;
13275
13282
}
13276
13283
}
13277
- let toolPath = yield tc.cacheDir(tempDir, 'node', version);
13284
+ let toolPath = yield tc.cacheDir(tempDir, 'node', version, arch );
13278
13285
core.addPath(toolPath);
13279
13286
return toolPath;
13280
13287
});
0 commit comments