@ -4694,6 +4694,7 @@ const installer = __importStar(__webpack_require__(749));
const auth = _ _importStar ( _ _webpack _require _ _ ( 202 ) ) ;
const auth = _ _importStar ( _ _webpack _require _ _ ( 202 ) ) ;
const path = _ _importStar ( _ _webpack _require _ _ ( 622 ) ) ;
const path = _ _importStar ( _ _webpack _require _ _ ( 622 ) ) ;
const url _1 = _ _webpack _require _ _ ( 835 ) ;
const url _1 = _ _webpack _require _ _ ( 835 ) ;
const os = _ _webpack _require _ _ ( 87 ) ;
function run ( ) {
function run ( ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
try {
try {
@ -4705,12 +4706,21 @@ function run() {
if ( ! version ) {
if ( ! version ) {
version = core . getInput ( 'version' ) ;
version = core . getInput ( 'version' ) ;
}
}
let arch = core . getInput ( 'architecture' ) ;
// if architecture supplied but node-version is not
// if we don't throw a warning, the already installed x64 node will be used which is not probably what user meant.
if ( arch && ! version ) {
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`' ) ;
}
if ( ! arch ) {
arch = os . arch ( ) ;
}
if ( version ) {
if ( version ) {
let token = core . getInput ( 'token' ) ;
let token = core . getInput ( 'token' ) ;
let auth = ! token || isGhes ( ) ? undefined : ` token ${ token } ` ;
let auth = ! token || isGhes ( ) ? undefined : ` token ${ token } ` ;
let stable = ( core . getInput ( 'stable' ) || 'true' ) . toUpperCase ( ) === 'TRUE' ;
let stable = ( core . getInput ( 'stable' ) || 'true' ) . toUpperCase ( ) === 'TRUE' ;
const checkLatest = ( core . getInput ( 'check-latest' ) || 'false' ) . toUpperCase ( ) === 'TRUE' ;
const checkLatest = ( core . getInput ( 'check-latest' ) || 'false' ) . toUpperCase ( ) === 'TRUE' ;
yield installer . getNode ( version , stable , checkLatest , auth ) ;
yield installer . getNode ( version , stable , checkLatest , auth , arch );
}
}
const registryUrl = core . getInput ( 'registry-url' ) ;
const registryUrl = core . getInput ( 'registry-url' ) ;
const alwaysAuth = core . getInput ( 'always-auth' ) ;
const alwaysAuth = core . getInput ( 'always-auth' ) ;
@ -13093,13 +13103,13 @@ const tc = __importStar(__webpack_require__(533));
const path = _ _importStar ( _ _webpack _require _ _ ( 622 ) ) ;
const path = _ _importStar ( _ _webpack _require _ _ ( 622 ) ) ;
const semver = _ _importStar ( _ _webpack _require _ _ ( 280 ) ) ;
const semver = _ _importStar ( _ _webpack _require _ _ ( 280 ) ) ;
const fs = _ _webpack _require _ _ ( 747 ) ;
const fs = _ _webpack _require _ _ ( 747 ) ;
function getNode ( versionSpec , stable , checkLatest , auth ) {
function getNode ( versionSpec , stable , checkLatest , auth , arch = os . arch ( ) ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
let osPlat = os . platform ( ) ;
let osPlat = os . platform ( ) ;
let osArch = translateArchToDistUrl ( os. arch( ) ) ;
let osArch = translateArchToDistUrl ( arch) ;
if ( checkLatest ) {
if ( checkLatest ) {
core . info ( 'Attempt to resolve the latest version from manifest...' ) ;
core . info ( 'Attempt to resolve the latest version from manifest...' ) ;
const resolvedVersion = yield resolveVersionFromManifest ( versionSpec , stable , auth );
const resolvedVersion = yield resolveVersionFromManifest ( versionSpec , stable , auth , osArch );
if ( resolvedVersion ) {
if ( resolvedVersion ) {
versionSpec = resolvedVersion ;
versionSpec = resolvedVersion ;
core . info ( ` Resolved as ' ${ versionSpec } ' ` ) ;
core . info ( ` Resolved as ' ${ versionSpec } ' ` ) ;
@ -13110,7 +13120,7 @@ function getNode(versionSpec, stable, checkLatest, auth) {
}
}
// check cache
// check cache
let toolPath ;
let toolPath ;
toolPath = tc . find ( 'node' , versionSpec );
toolPath = tc . find ( 'node' , versionSpec , osArch );
// If not found in cache, download
// If not found in cache, download
if ( toolPath ) {
if ( toolPath ) {
core . info ( ` Found in cache @ ${ toolPath } ` ) ;
core . info ( ` Found in cache @ ${ toolPath } ` ) ;
@ -13123,9 +13133,9 @@ function getNode(versionSpec, stable, checkLatest, auth) {
// Try download from internal distribution (popular versions only)
// Try download from internal distribution (popular versions only)
//
//
try {
try {
info = yield getInfoFromManifest ( versionSpec , stable , auth );
info = yield getInfoFromManifest ( versionSpec , stable , auth , osArch );
if ( info ) {
if ( info ) {
core . info ( ` Acquiring ${ info . resolvedVersion } from ${ info . downloadUrl } ` ) ;
core . info ( ` Acquiring ${ info . resolvedVersion } - ${ info . arch } from ${ info . downloadUrl } ` ) ;
downloadPath = yield tc . downloadTool ( info . downloadUrl , undefined , auth ) ;
downloadPath = yield tc . downloadTool ( info . downloadUrl , undefined , auth ) ;
}
}
else {
else {
@ -13148,17 +13158,17 @@ function getNode(versionSpec, stable, checkLatest, auth) {
// Download from nodejs.org
// Download from nodejs.org
//
//
if ( ! downloadPath ) {
if ( ! downloadPath ) {
info = yield getInfoFromDist ( versionSpec );
info = yield getInfoFromDist ( versionSpec , arch );
if ( ! info ) {
if ( ! info ) {
throw new Error ( ` Unable to find Node version ' ${ versionSpec } ' for platform ${ osPlat } and architecture ${ osArch } . ` ) ;
throw new Error ( ` Unable to find Node version ' ${ versionSpec } ' for platform ${ osPlat } and architecture ${ osArch } . ` ) ;
}
}
core . info ( ` Acquiring ${ info . resolvedVersion } from ${ info . downloadUrl } ` ) ;
core . info ( ` Acquiring ${ info . resolvedVersion } - ${ info . arch } from ${ info . downloadUrl } ` ) ;
try {
try {
downloadPath = yield tc . downloadTool ( info . downloadUrl ) ;
downloadPath = yield tc . downloadTool ( info . downloadUrl ) ;
}
}
catch ( err ) {
catch ( err ) {
if ( err instanceof tc . HTTPError && err . httpStatusCode == 404 ) {
if ( err instanceof tc . HTTPError && err . httpStatusCode == 404 ) {
return yield acquireNodeFromFallbackLocation ( info . resolvedVersion );
return yield acquireNodeFromFallbackLocation ( info . resolvedVersion , info . arch );
}
}
throw err ;
throw err ;
}
}
@ -13189,7 +13199,7 @@ function getNode(versionSpec, stable, checkLatest, auth) {
// Install into the local tool cache - node extracts with a root folder that matches the fileName downloaded
// Install into the local tool cache - node extracts with a root folder that matches the fileName downloaded
//
//
core . info ( 'Adding to the cache ...' ) ;
core . info ( 'Adding to the cache ...' ) ;
toolPath = yield tc . cacheDir ( extPath , 'node' , info . resolvedVersion );
toolPath = yield tc . cacheDir ( extPath , 'node' , info . resolvedVersion , info . arch );
core . info ( 'Done' ) ;
core . info ( 'Done' ) ;
}
}
//
//
@ -13206,26 +13216,27 @@ function getNode(versionSpec, stable, checkLatest, auth) {
} ) ;
} ) ;
}
}
exports . getNode = getNode ;
exports . getNode = getNode ;
function getInfoFromManifest ( versionSpec , stable , auth ) {
function getInfoFromManifest ( versionSpec , stable , auth , osArch = translateArchToDistUrl ( os . arch ( ) ) ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
let info = null ;
let info = null ;
const releases = yield tc . getManifestFromRepo ( 'actions' , 'node-versions' , auth , 'main' ) ;
const releases = yield tc . getManifestFromRepo ( 'actions' , 'node-versions' , auth , 'main' ) ;
const rel = yield tc . findFromManifest ( versionSpec , stable , releases );
const rel = yield tc . findFromManifest ( versionSpec , stable , releases , osArch );
if ( rel && rel . files . length > 0 ) {
if ( rel && rel . files . length > 0 ) {
info = { } ;
info = { } ;
info . resolvedVersion = rel . version ;
info . resolvedVersion = rel . version ;
info . arch = rel . files [ 0 ] . arch ;
info . downloadUrl = rel . files [ 0 ] . download _url ;
info . downloadUrl = rel . files [ 0 ] . download _url ;
info . fileName = rel . files [ 0 ] . filename ;
info . fileName = rel . files [ 0 ] . filename ;
}
}
return info ;
return info ;
} ) ;
} ) ;
}
}
function getInfoFromDist ( versionSpec ) {
function getInfoFromDist ( versionSpec , arch = os . arch ( ) ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
let osPlat = os . platform ( ) ;
let osPlat = os . platform ( ) ;
let osArch = translateArchToDistUrl ( os. arch( ) ) ;
let osArch = translateArchToDistUrl ( arch) ;
let version ;
let version ;
version = yield queryDistForMatch ( versionSpec );
version = yield queryDistForMatch ( versionSpec , arch );
if ( ! version ) {
if ( ! version ) {
return null ;
return null ;
}
}
@ -13241,14 +13252,15 @@ function getInfoFromDist(versionSpec) {
return {
return {
downloadUrl : url ,
downloadUrl : url ,
resolvedVersion : version ,
resolvedVersion : version ,
arch : arch ,
fileName : fileName
fileName : fileName
} ;
} ;
} ) ;
} ) ;
}
}
function resolveVersionFromManifest ( versionSpec , stable , auth ) {
function resolveVersionFromManifest ( versionSpec , stable , auth , osArch = translateArchToDistUrl ( os . arch ( ) ) ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
try {
try {
const info = yield getInfoFromManifest ( versionSpec , stable , auth );
const info = yield getInfoFromManifest ( versionSpec , stable , auth , osArch );
return info === null || info === void 0 ? void 0 : info . resolvedVersion ;
return info === null || info === void 0 ? void 0 : info . resolvedVersion ;
}
}
catch ( err ) {
catch ( err ) {
@ -13283,10 +13295,10 @@ function evaluateVersions(versions, versionSpec) {
}
}
return version ;
return version ;
}
}
function queryDistForMatch ( versionSpec ) {
function queryDistForMatch ( versionSpec , arch = os . arch ( ) ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
let osPlat = os . platform ( ) ;
let osPlat = os . platform ( ) ;
let osArch = translateArchToDistUrl ( os. arch( ) ) ;
let osArch = translateArchToDistUrl ( arch) ;
// node offers a json list of versions
// node offers a json list of versions
let dataFileName ;
let dataFileName ;
switch ( osPlat ) {
switch ( osPlat ) {
@ -13339,10 +13351,10 @@ exports.getVersionsFromDist = getVersionsFromDist;
// This method attempts to download and cache the resources from these alternative locations.
// This method attempts to download and cache the resources from these alternative locations.
// Note also that the files are normally zipped but in this case they are just an exe
// Note also that the files are normally zipped but in this case they are just an exe
// and lib file in a folder, not zipped.
// and lib file in a folder, not zipped.
function acquireNodeFromFallbackLocation ( version ) {
function acquireNodeFromFallbackLocation ( version , arch = os . arch ( ) ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
let osPlat = os . platform ( ) ;
let osPlat = os . platform ( ) ;
let osArch = translateArchToDistUrl ( os. arch( ) ) ;
let osArch = translateArchToDistUrl ( arch) ;
// Create temporary folder to download in to
// Create temporary folder to download in to
const tempDownloadFolder = 'temp_' + Math . floor ( Math . random ( ) * 2000000000 ) ;
const tempDownloadFolder = 'temp_' + Math . floor ( Math . random ( ) * 2000000000 ) ;
const tempDirectory = process . env [ 'RUNNER_TEMP' ] || '' ;
const tempDirectory = process . env [ 'RUNNER_TEMP' ] || '' ;
@ -13373,7 +13385,7 @@ function acquireNodeFromFallbackLocation(version) {
throw err ;
throw err ;
}
}
}
}
let toolPath = yield tc . cacheDir ( tempDir , 'node' , version );
let toolPath = yield tc . cacheDir ( tempDir , 'node' , version , arch );
core . addPath ( toolPath ) ;
core . addPath ( toolPath ) ;
return toolPath ;
return toolPath ;
} ) ;
} ) ;