fix: exclude prereleases when resolving latest/current/node aliases (#1668)

* exclude prereleases when resolving latest/current/node aliases

* test: verify stable install succeeds when skipping prereleases

---------

Co-authored-by: gowridurgad <gowridurgad@gmail.com>
This commit is contained in:
v-gowridurgadandgowridurgad authored and GitHub committed 2026-11-17 10:09:09 -06:00
1 parent 436c65619b
commit 66f83c8206
5 files changed
+136 -5

No files matched your search

@@ -3,6 +3,7 @@ import path from 'node:path';
import * as core from '@actions/core';
import * as exec from '@actions/exec';
import * as tc from '@actions/tool-cache';
import semver from 'semver';
import BaseDistribution from '../base-distribution.js';
import {NodeInputs, INodeVersion, INodeVersionInfo} from '../base-models.js';
@@ -195,7 +196,18 @@ export default class OfficialBuilds extends BaseDistribution {
if (this.isLatestSyntax(this.nodeInfo.versionSpec)) {
core.info(`getting latest node version...`);
return versions[0];
const stableVersion = versions.find(
potential => semver.prerelease(potential) === null
);
if (!stableVersion) {
throw new Error(
`Unable to find a stable Node version for '${this.nodeInfo.versionSpec}' on platform ${this.osPlat} and architecture ${this.nodeInfo.arch}.`
);
}
return stableVersion;
}
version = super.evaluateVersions(versions);