Change the logic to support A.B.Cxx
This commit is contained in:
parent
920b830bd1
commit
4f6b2f576a
|
@ -12,7 +12,7 @@ import {IS_LINUX, IS_WINDOWS} from './utils';
|
||||||
import {QualityOptions} from './setup-dotnet';
|
import {QualityOptions} from './setup-dotnet';
|
||||||
|
|
||||||
export interface DotnetVersion {
|
export interface DotnetVersion {
|
||||||
type: string;
|
type: string | null;
|
||||||
value: string;
|
value: string;
|
||||||
qualityFlag: boolean;
|
qualityFlag: boolean;
|
||||||
}
|
}
|
||||||
|
@ -27,20 +27,23 @@ export class DotnetVersionResolver {
|
||||||
}
|
}
|
||||||
|
|
||||||
private async resolveVersionInput(): Promise<void> {
|
private async resolveVersionInput(): Promise<void> {
|
||||||
if (!semver.validRange(this.inputVersion)) {
|
const isLatestPatchSyntax = /^\d+\.\d+\.\d{1}x{2}$/.test(this.inputVersion);
|
||||||
|
if (!semver.validRange(this.inputVersion) && !isLatestPatchSyntax) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`'dotnet-version' was supplied in invalid format: ${this.inputVersion}! Supported syntax: A.B.C, A.B, A.B.x, A, A.x`
|
`'dotnet-version' was supplied in invalid format: ${this.inputVersion}! Supported syntax: A.B.C, A.B, A.B.x, A, A.x, A.B.Cxx`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (semver.valid(this.inputVersion)) {
|
if (semver.valid(this.inputVersion)) {
|
||||||
this.resolvedArgument.type = 'version';
|
this.resolvedArgument.type = 'version';
|
||||||
this.resolvedArgument.value = this.inputVersion;
|
this.resolvedArgument.value = this.inputVersion;
|
||||||
|
} else if (!this.inputVersion) {
|
||||||
|
this.resolvedArgument.type = null;
|
||||||
} else {
|
} else {
|
||||||
const [major, minor] = this.inputVersion.split('.');
|
|
||||||
|
|
||||||
if (this.isNumericTag(major)) {
|
|
||||||
this.resolvedArgument.type = 'channel';
|
this.resolvedArgument.type = 'channel';
|
||||||
if (this.isNumericTag(minor)) {
|
const [major, minor] = this.inputVersion.split('.');
|
||||||
|
if (isLatestPatchSyntax) {
|
||||||
|
this.resolvedArgument.value = this.inputVersion;
|
||||||
|
} 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', [], {
|
const httpClient = new hc.HttpClient('actions/setup-dotnet', [], {
|
||||||
|
@ -52,7 +55,6 @@ export class DotnetVersionResolver {
|
||||||
[major, minor]
|
[major, minor]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
this.resolvedArgument.qualityFlag = +major >= 6 ? true : false;
|
this.resolvedArgument.qualityFlag = +major >= 6 ? true : false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,11 +63,7 @@ export class DotnetVersionResolver {
|
||||||
return /^\d+$/.test(versionTag);
|
return /^\d+$/.test(versionTag);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async createDotNetVersion(): Promise<{
|
public async createDotNetVersion(): Promise<DotnetVersion> {
|
||||||
type: string;
|
|
||||||
value: string;
|
|
||||||
qualityFlag: boolean;
|
|
||||||
}> {
|
|
||||||
await this.resolveVersionInput();
|
await this.resolveVersionInput();
|
||||||
if (!this.resolvedArgument.type) {
|
if (!this.resolvedArgument.type) {
|
||||||
return this.resolvedArgument;
|
return this.resolvedArgument;
|
||||||
|
|
Loading…
Reference in New Issue