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}`;
|
this.resolvedArgument.value = `${major}.${minor}`;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const httpClient = new hc.HttpClient('actions/setup-dotnet', [], {
|
this.resolvedArgument.value = yield this.getLatestByMajorTag(major);
|
||||||
allowRetries: true,
|
|
||||||
maxRetries: 3
|
|
||||||
});
|
|
||||||
this.resolvedArgument.value = yield this.getLatestVersion(httpClient, [
|
|
||||||
major,
|
|
||||||
minor
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
this.resolvedArgument.qualityFlag = +major >= 6 ? true : false;
|
this.resolvedArgument.qualityFlag = +major >= 6 ? true : false;
|
||||||
}
|
}
|
||||||
@ -301,17 +294,21 @@ class DotnetVersionResolver {
|
|||||||
return this.resolvedArgument;
|
return this.resolvedArgument;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
getLatestVersion(httpClient, versionParts) {
|
getLatestByMajorTag(majorTag) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
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 response = yield httpClient.getJson(DotnetVersionResolver.DotNetCoreIndexUrl);
|
||||||
const result = response.result || {};
|
const result = response.result || {};
|
||||||
const releasesInfo = result['releases-index'];
|
const releasesInfo = result['releases-index'];
|
||||||
const releaseInfo = releasesInfo.find(info => {
|
const releaseInfo = releasesInfo.find(info => {
|
||||||
const sdkParts = info['channel-version'].split('.');
|
const sdkParts = info['channel-version'].split('.');
|
||||||
return sdkParts[0] === versionParts[0];
|
return sdkParts[0] === majorTag;
|
||||||
});
|
});
|
||||||
if (!releaseInfo) {
|
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'];
|
return releaseInfo['channel-version'];
|
||||||
});
|
});
|
||||||
|
@ -44,14 +44,7 @@ export class DotnetVersionResolver {
|
|||||||
} else if (this.isNumericTag(major) && this.isNumericTag(minor)) {
|
} else if (this.isNumericTag(major) && this.isNumericTag(minor)) {
|
||||||
this.resolvedArgument.value = `${major}.${minor}`;
|
this.resolvedArgument.value = `${major}.${minor}`;
|
||||||
} else {
|
} else {
|
||||||
const httpClient = new hc.HttpClient('actions/setup-dotnet', [], {
|
this.resolvedArgument.value = await this.getLatestByMajorTag(major);
|
||||||
allowRetries: true,
|
|
||||||
maxRetries: 3
|
|
||||||
});
|
|
||||||
this.resolvedArgument.value = await this.getLatestVersion(httpClient, [
|
|
||||||
major,
|
|
||||||
minor
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
this.resolvedArgument.qualityFlag = +major >= 6 ? true : false;
|
this.resolvedArgument.qualityFlag = +major >= 6 ? true : false;
|
||||||
}
|
}
|
||||||
@ -76,10 +69,11 @@ export class DotnetVersionResolver {
|
|||||||
return this.resolvedArgument;
|
return this.resolvedArgument;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async getLatestVersion(
|
private async getLatestByMajorTag(majorTag: string): Promise<string> {
|
||||||
httpClient: hc.HttpClient,
|
const httpClient = new hc.HttpClient('actions/setup-dotnet', [], {
|
||||||
versionParts: string[]
|
allowRetries: true,
|
||||||
): Promise<string> {
|
maxRetries: 3
|
||||||
|
});
|
||||||
const response = await httpClient.getJson<any>(
|
const response = await httpClient.getJson<any>(
|
||||||
DotnetVersionResolver.DotNetCoreIndexUrl
|
DotnetVersionResolver.DotNetCoreIndexUrl
|
||||||
);
|
);
|
||||||
@ -88,14 +82,12 @@ export class DotnetVersionResolver {
|
|||||||
|
|
||||||
const releaseInfo = releasesInfo.find(info => {
|
const releaseInfo = releasesInfo.find(info => {
|
||||||
const sdkParts: string[] = info['channel-version'].split('.');
|
const sdkParts: string[] = info['channel-version'].split('.');
|
||||||
return sdkParts[0] === versionParts[0];
|
return sdkParts[0] === majorTag;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!releaseInfo) {
|
if (!releaseInfo) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Could not find info for version ${versionParts.join('.')} at ${
|
`Could not find info for version with major tag: v${majorTag} at ${DotnetVersionResolver.DotNetCoreIndexUrl}`
|
||||||
DotnetVersionResolver.DotNetCoreIndexUrl
|
|
||||||
}`
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user