You've already forked setup-dotnet
mirror of
https://github.com/actions/setup-dotnet.git
synced 2025-10-16 08:15:10 +07:00
Add ability to write resolved version of SDK into the output variable (#324)
This commit is contained in:
@ -2,6 +2,7 @@ import * as core from '@actions/core';
|
||||
import {DotnetCoreInstaller} from './installer';
|
||||
import * as fs from 'fs';
|
||||
import path from 'path';
|
||||
import semver from 'semver';
|
||||
import * as auth from './authutil';
|
||||
|
||||
const qualityOptions = [
|
||||
@ -26,6 +27,7 @@ export async function run() {
|
||||
// Proxy, auth, (etc) are still set up, even if no version is identified
|
||||
//
|
||||
const versions = core.getMultilineInput('dotnet-version');
|
||||
const installedDotnetVersions: string[] = [];
|
||||
|
||||
const globalJsonFileInput = core.getInput('global-json-file');
|
||||
if (globalJsonFileInput) {
|
||||
@ -60,7 +62,8 @@ export async function run() {
|
||||
const uniqueVersions = new Set<string>(versions);
|
||||
for (const version of uniqueVersions) {
|
||||
dotnetInstaller = new DotnetCoreInstaller(version, quality);
|
||||
await dotnetInstaller.installDotnet();
|
||||
const installedVersion = await dotnetInstaller.installDotnet();
|
||||
installedDotnetVersions.push(installedVersion);
|
||||
}
|
||||
DotnetCoreInstaller.addToPath();
|
||||
}
|
||||
@ -71,6 +74,20 @@ export async function run() {
|
||||
auth.configAuthentication(sourceUrl, configFile);
|
||||
}
|
||||
|
||||
const comparisonRange: string = globalJsonFileInput
|
||||
? versions[versions.length - 1]!
|
||||
: '*';
|
||||
|
||||
const versionToOutput = semver.maxSatisfying(
|
||||
installedDotnetVersions,
|
||||
comparisonRange,
|
||||
{
|
||||
includePrerelease: true
|
||||
}
|
||||
);
|
||||
|
||||
core.setOutput('dotnet-version', versionToOutput);
|
||||
|
||||
const matchersPath = path.join(__dirname, '..', '.github');
|
||||
core.info(`##[add-matcher]${path.join(matchersPath, 'csc.json')}`);
|
||||
} catch (error) {
|
||||
|
Reference in New Issue
Block a user