diff --git a/dist/index.js b/dist/index.js index 423a712..6a33cee 100644 --- a/dist/index.js +++ b/dist/index.js @@ -268,14 +268,7 @@ class DotnetVersionResolver { this.resolvedArgument.value = `${major}.${minor}`; } else { - const httpClient = new hc.HttpClient('actions/setup-dotnet', [], { - allowRetries: true, - maxRetries: 3 - }); - this.resolvedArgument.value = yield this.getLatestVersion(httpClient, [ - major, - minor - ]); + this.resolvedArgument.value = yield this.getLatestByMajorTag(major); } this.resolvedArgument.qualityFlag = +major >= 6 ? true : false; } @@ -301,17 +294,21 @@ class DotnetVersionResolver { return this.resolvedArgument; }); } - getLatestVersion(httpClient, versionParts) { + getLatestByMajorTag(majorTag) { return __awaiter(this, void 0, void 0, function* () { + const httpClient = new hc.HttpClient('actions/setup-dotnet', [], { + allowRetries: true, + maxRetries: 3 + }); const response = yield 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] === versionParts[0]; + return sdkParts[0] === majorTag; }); if (!releaseInfo) { - throw new Error(`Could not find info for version ${versionParts.join('.')} at ${DotnetVersionResolver.DotNetCoreIndexUrl}`); + throw new Error(`Could not find info for version with major tag: v${majorTag} at ${DotnetVersionResolver.DotNetCoreIndexUrl}`); } return releaseInfo['channel-version']; }); diff --git a/src/installer.ts b/src/installer.ts index 62b85d4..ec89a79 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -44,14 +44,7 @@ export class DotnetVersionResolver { } else if (this.isNumericTag(major) && this.isNumericTag(minor)) { this.resolvedArgument.value = `${major}.${minor}`; } else { - const httpClient = new hc.HttpClient('actions/setup-dotnet', [], { - allowRetries: true, - maxRetries: 3 - }); - this.resolvedArgument.value = await this.getLatestVersion(httpClient, [ - major, - minor - ]); + this.resolvedArgument.value = await this.getLatestByMajorTag(major); } this.resolvedArgument.qualityFlag = +major >= 6 ? true : false; } @@ -76,10 +69,11 @@ export class DotnetVersionResolver { return this.resolvedArgument; } - private async getLatestVersion( - httpClient: hc.HttpClient, - versionParts: string[] - ): Promise { + 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 ); @@ -88,14 +82,12 @@ export class DotnetVersionResolver { const releaseInfo = releasesInfo.find(info => { const sdkParts: string[] = info['channel-version'].split('.'); - return sdkParts[0] === versionParts[0]; + return sdkParts[0] === majorTag; }); if (!releaseInfo) { throw new Error( - `Could not find info for version ${versionParts.join('.')} at ${ - DotnetVersionResolver.DotNetCoreIndexUrl - }` + `Could not find info for version with major tag: v${majorTag} at ${DotnetVersionResolver.DotNetCoreIndexUrl}` ); }