From 75d47e04fb37f2e19ce885f1cb895db1bd78d933 Mon Sep 17 00:00:00 2001 From: IvanZosimov Date: Wed, 28 Sep 2022 13:44:37 +0200 Subject: [PATCH] Change logic of outputting when global.json is used --- dist/index.js | 9 +++++++-- src/setup-dotnet.ts | 19 ++++++++++++++----- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/dist/index.js b/dist/index.js index a167ab0..bf3e1cd 100644 --- a/dist/index.js +++ b/dist/index.js @@ -483,9 +483,14 @@ function run() { if (sourceUrl) { auth.configAuthentication(sourceUrl, configFile); } - core.setOutput('dotnet-version', semver_1.default.maxSatisfying(installedDotnetVersions, '*', { + const comparisonRange = globalJsonFileInput + ? versions.at(-1) + : '*'; + const includePrereleaseOption = { includePrerelease: true - })); + }; + const versionToOutput = semver_1.default.maxSatisfying(installedDotnetVersions, comparisonRange, includePrereleaseOption); + core.setOutput('dotnet-version', versionToOutput); const matchersPath = path_1.default.join(__dirname, '..', '.github'); core.info(`##[add-matcher]${path_1.default.join(matchersPath, 'csc.json')}`); } diff --git a/src/setup-dotnet.ts b/src/setup-dotnet.ts index 6246b3b..5cdb880 100644 --- a/src/setup-dotnet.ts +++ b/src/setup-dotnet.ts @@ -74,13 +74,22 @@ export async function run() { auth.configAuthentication(sourceUrl, configFile); } - core.setOutput( - 'dotnet-version', - semver.maxSatisfying(installedDotnetVersions, '*', { - includePrerelease: true - }) + const comparisonRange: string = globalJsonFileInput + ? versions.at(-1)! + : '*'; + + const includePrereleaseOption = { + includePrerelease: true + }; + + const versionToOutput = semver.maxSatisfying( + installedDotnetVersions, + comparisonRange, + includePrereleaseOption ); + core.setOutput('dotnet-version', versionToOutput); + const matchersPath = path.join(__dirname, '..', '.github'); core.info(`##[add-matcher]${path.join(matchersPath, 'csc.json')}`); } catch (error) {