mirror of
https://github.com/actions/setup-dotnet.git
synced 2024-11-22 19:41:08 +07:00
Update resolveVersionInput()
This commit is contained in:
parent
f199d27aa1
commit
0318091611
19
dist/index.js
vendored
19
dist/index.js
vendored
@ -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'];
|
||||
});
|
||||
|
@ -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<string> {
|
||||
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
|
||||
);
|
||||
@ -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}`
|
||||
);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user