Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 16 additions & 20 deletions dist/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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.
Expand All @@ -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 {
Expand Down
48 changes: 16 additions & 32 deletions src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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';
Expand All @@ -95,36 +109,6 @@ export class DotnetVersionResolver {
}
return this.resolvedArgument;
}

private async getLatestByMajorTag(majorTag: string): Promise<string> {
const httpClient = new hc.HttpClient('actions/setup-dotnet', [], {
allowRetries: true,
maxRetries: 3
});

const response = await httpClient.getJson<any>(
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 {
Expand Down
Loading