diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 3367ec2..38282ff 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -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 }} diff --git a/action.yml b/action.yml index bc40dab..4e29429 100644 --- a/action.yml +++ b/action.yml @@ -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: diff --git a/dist/index.js b/dist/index.js index e00d5b6..be51046 100644 --- a/dist/index.js +++ b/dist/index.js @@ -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 diff --git a/src/installer.ts b/src/installer.ts index 5f77618..83b2cf7 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -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'));