diff --git a/dist/setup/index.js b/dist/setup/index.js index b6aece171..405bcdf9b 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -78681,7 +78681,6 @@ exports.normalizeArch = normalizeArch; const core = __importStar(__nccwpck_require__(42186)); const exec = __importStar(__nccwpck_require__(71514)); const io = __importStar(__nccwpck_require__(47351)); -const hc = __importStar(__nccwpck_require__(96255)); const fs_1 = __nccwpck_require__(57147); const path_1 = __importDefault(__nccwpck_require__(71017)); const os_1 = __importDefault(__nccwpck_require__(22037)); @@ -78732,7 +78731,22 @@ class DotnetVersionResolver { this.resolvedArgument.value = `${major}.${minor}`; } else if (this.isNumericTag(major)) { - this.resolvedArgument.value = await this.getLatestByMajorTag(major); + // Starting with .NET 5, the minor version is always zero. + // Hardcode the earlier versions because they will not get new releases. + switch (major) { + case '1': + this.resolvedArgument.value = '1.1'; + break; + case '2': + this.resolvedArgument.value = '2.2'; + break; + case '3': + this.resolvedArgument.value = '3.1'; + break; + default: + this.resolvedArgument.value = `${major}.0`; + break; + } } else { // If "dotnet-version" is specified as *, x or X resolve latest version of .NET explicitly from LTS channel. The version argument will default to "latest" by install-dotnet script. @@ -78756,24 +78770,6 @@ class DotnetVersionResolver { } return this.resolvedArgument; } - async getLatestByMajorTag(majorTag) { - const httpClient = new hc.HttpClient('actions/setup-dotnet', [], { - allowRetries: true, - maxRetries: 3 - }); - const response = await httpClient.getJson(DotnetVersionResolver.DotnetCoreIndexUrl); - const result = response.result || {}; - const releasesInfo = result['releases-index']; - const releaseInfo = releasesInfo.find(info => { - const sdkParts = info['channel-version'].split('.'); - return sdkParts[0] === majorTag; - }); - if (!releaseInfo) { - throw new Error(`Could not find info for version with major tag: "${majorTag}" at ${DotnetVersionResolver.DotnetCoreIndexUrl}`); - } - return releaseInfo['channel-version']; - } - static DotnetCoreIndexUrl = 'https://builds.dotnet.microsoft.com/dotnet/release-metadata/releases-index.json'; } exports.DotnetVersionResolver = DotnetVersionResolver; class DotnetInstallScript { diff --git a/src/installer.ts b/src/installer.ts index 451c66c48..4ed19bbdf 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -2,7 +2,6 @@ import * as core from '@actions/core'; import * as exec from '@actions/exec'; import * as io from '@actions/io'; -import * as hc from '@actions/http-client'; import {chmodSync} from 'fs'; import path from 'path'; import os from 'os'; @@ -72,7 +71,22 @@ export class DotnetVersionResolver { } else if (this.isNumericTag(major) && this.isNumericTag(minor)) { this.resolvedArgument.value = `${major}.${minor}`; } else if (this.isNumericTag(major)) { - this.resolvedArgument.value = await this.getLatestByMajorTag(major); + // Starting with .NET 5, the minor version is always zero. + // Hardcode the earlier versions because they will not get new releases. + switch (major) { + case '1': + this.resolvedArgument.value = '1.1'; + break; + case '2': + this.resolvedArgument.value = '2.2'; + break; + case '3': + this.resolvedArgument.value = '3.1'; + break; + default: + this.resolvedArgument.value = `${major}.0`; + break; + } } else { // If "dotnet-version" is specified as *, x or X resolve latest version of .NET explicitly from LTS channel. The version argument will default to "latest" by install-dotnet script. this.resolvedArgument.value = 'LTS'; @@ -95,36 +109,6 @@ export class DotnetVersionResolver { } return this.resolvedArgument; } - - private async getLatestByMajorTag(majorTag: string): Promise { - const httpClient = new hc.HttpClient('actions/setup-dotnet', [], { - allowRetries: true, - maxRetries: 3 - }); - - const response = await httpClient.getJson( - DotnetVersionResolver.DotnetCoreIndexUrl - ); - - const result = response.result || {}; - const releasesInfo: any[] = result['releases-index']; - - const releaseInfo = releasesInfo.find(info => { - const sdkParts: string[] = info['channel-version'].split('.'); - return sdkParts[0] === majorTag; - }); - - if (!releaseInfo) { - throw new Error( - `Could not find info for version with major tag: "${majorTag}" at ${DotnetVersionResolver.DotnetCoreIndexUrl}` - ); - } - - return releaseInfo['channel-version']; - } - - static DotnetCoreIndexUrl = - 'https://builds.dotnet.microsoft.com/dotnet/release-metadata/releases-index.json'; } export class DotnetInstallScript {