Fixed review points

This commit is contained in:
IvanZosimov 2022-08-18 14:47:05 +02:00
parent f2b31909b2
commit 18b0a81f30
4 changed files with 24 additions and 25 deletions

View File

@ -160,13 +160,9 @@ jobs:
uses: ./
with:
dotnet-version: 2.2.X
- name: Setup dotnet 3.0.*
uses: ./
with:
dotnet-version: 3.0.*
- name: Verify dotnet
shell: pwsh
run: __tests__/verify-dotnet.ps1 '2.2' '3.0' '3.1'
run: __tests__/verify-dotnet.ps1 '2.2' '3.1'
test-setup-with-wildcard:
runs-on: ${{ matrix.operating-system }}

View File

@ -8,7 +8,7 @@ inputs:
dotnet-version:
description: 'Optional SDK version(s) to use. If not provided, will install global.json version when available. Examples: 2.2.104, 3.1, 3.1.x'
dotnet-quality:
description: 'Optional quality of the build. The possible values are: daily, signed, validated, preview, GA.'
description: 'Optional quality of the build. The possible values are: daily, signed, validated, preview, ga.'
global-json-file:
description: 'Optional global.json location, if your global.json isn''t located in the root of the repo.'
source-url:

18
dist/index.js vendored
View File

@ -213,7 +213,7 @@ class DotnetVersionResolver {
resolveVersionInput() {
if (!semver_1.default.valid(this.inputVersion) &&
!semver_1.default.validRange(this.inputVersion)) {
throw new Error(`'dotnet-version' was supplied in invalid format: ${this.inputVersion}! Supported syntax: A.B.C, A.B.C-D, A.B.x, A.B.X, A.B.*`);
throw new Error(`'dotnet-version' was supplied in invalid format: ${this.inputVersion}! Supported syntax: A.B, A.B.C, A.B.C-D, A.B.x, A.B.X, A.B.*`);
}
if (semver_1.default.valid(this.inputVersion)) {
this.resolvedArgument.type = 'version';
@ -222,12 +222,13 @@ class DotnetVersionResolver {
else {
this.resolvedArgument.type = 'channel';
this.resolvedArgument.qualityFlag = true;
this.resolvedArgument.value = semver_1.default.validRange(this.inputVersion)
? this.inputVersion
.split('.')
.slice(0, 2)
.join('.')
: this.inputVersion;
if (semver_1.default.validRange(this.inputVersion)) {
let coercedVersion = semver_1.default.coerce(this.inputVersion);
this.resolvedArgument.value = (coercedVersion === null || coercedVersion === void 0 ? void 0 : coercedVersion.major) + "." + (coercedVersion === null || coercedVersion === void 0 ? void 0 : coercedVersion.minor);
}
else {
this.resolvedArgument.value = this.inputVersion;
}
}
}
createVersionObject() {
@ -344,11 +345,12 @@ class DotnetCoreInstaller {
}
else {
if (IS_WINDOWS) {
core.addPath(DotnetCoreInstaller.installationDirectoryWindows);
core.exportVariable('DOTNET_ROOT', DotnetCoreInstaller.installationDirectoryWindows);
}
else if (IS_LINUX) {
core.exportVariable('DOTNET_ROOT', DotnetCoreInstaller.installationDirectoryLinux);
core.addPath(DotnetCoreInstaller.installationDirectoryLinux);
core.exportVariable('DOTNET_ROOT', DotnetCoreInstaller.installationDirectoryLinux);
}
else {
// This is the default set in install-dotnet.sh

View File

@ -45,7 +45,7 @@ export class DotnetVersionResolver {
!semver.validRange(this.inputVersion)
) {
throw new Error(
`'dotnet-version' was supplied in invalid format: ${this.inputVersion}! Supported syntax: A.B.C, A.B.C-D, A.B.x, A.B.X, A.B.*`
`'dotnet-version' was supplied in invalid format: ${this.inputVersion}! Supported syntax: A.B, A.B.C, A.B.C-D, A.B.x, A.B.X, A.B.*`
);
}
if (semver.valid(this.inputVersion)) {
@ -54,12 +54,12 @@ export class DotnetVersionResolver {
} else {
this.resolvedArgument.type = 'channel';
this.resolvedArgument.qualityFlag = true;
this.resolvedArgument.value = semver.validRange(this.inputVersion)
? this.inputVersion
.split('.')
.slice(0, 2)
.join('.')
: this.inputVersion;
if (semver.validRange(this.inputVersion)) {
let coercedVersion = semver.coerce(this.inputVersion);
this.resolvedArgument.value = coercedVersion?.major + "." + coercedVersion?.minor;
} else {
this.resolvedArgument.value = this.inputVersion;
}
}
}
@ -83,8 +83,8 @@ export class DotnetVersionResolver {
export class DotnetCoreInstaller {
private version: string;
private quality: string;
static installationDirectoryWindows = path.join(process.env['PROGRAMFILES'] + '', "dotnet");
static installationDirectoryLinux = '/usr/share/dotnet';
static readonly installationDirectoryWindows = path.join(process.env['PROGRAMFILES'] + '', "dotnet");
static readonly installationDirectoryLinux = '/usr/share/dotnet';
constructor(version: string, quality: string) {
this.version = version;
@ -204,17 +204,18 @@ export class DotnetCoreInstaller {
core.exportVariable('DOTNET_ROOT', process.env['DOTNET_INSTALL_DIR']);
} else {
if (IS_WINDOWS) {
core.addPath(DotnetCoreInstaller.installationDirectoryWindows);
core.exportVariable(
'DOTNET_ROOT',
DotnetCoreInstaller.installationDirectoryWindows
);
}
else if (IS_LINUX) {
core.addPath(DotnetCoreInstaller.installationDirectoryLinux);
core.exportVariable(
'DOTNET_ROOT',
DotnetCoreInstaller.installationDirectoryLinux
);
core.addPath(DotnetCoreInstaller.installationDirectoryLinux);
);
} else {
// This is the default set in install-dotnet.sh
core.addPath(path.join(process.env['HOME'] + '', '.dotnet'));