mirror of
https://github.com/actions/setup-dotnet.git
synced 2025-08-18 14:45:09 +00:00
Implement dotnet-version output
This commit is contained in:
parent
0705ef0281
commit
a77dbf07aa
@ -17,6 +17,9 @@ inputs:
|
|||||||
description: 'Optional OWNER for using packages from GitHub Package Registry organizations/users other than the current repository''s owner. Only used if a GPR URL is also provided in source-url'
|
description: 'Optional OWNER for using packages from GitHub Package Registry organizations/users other than the current repository''s owner. Only used if a GPR URL is also provided in source-url'
|
||||||
config-file:
|
config-file:
|
||||||
description: 'Optional NuGet.config location, if your NuGet.config isn''t located in the root of the repo.'
|
description: 'Optional NuGet.config location, if your NuGet.config isn''t located in the root of the repo.'
|
||||||
|
outputs:
|
||||||
|
dotnet-version:
|
||||||
|
description: 'Contains the installed by action .NET SDK version for reuse.'
|
||||||
runs:
|
runs:
|
||||||
using: 'node16'
|
using: 'node16'
|
||||||
main: 'dist/index.js'
|
main: 'dist/index.js'
|
||||||
|
25
dist/index.js
vendored
25
dist/index.js
vendored
@ -356,8 +356,25 @@ class DotnetCoreInstaller {
|
|||||||
if (exitCode) {
|
if (exitCode) {
|
||||||
throw new Error(`Failed to install dotnet ${exitCode}. ${stdout}`);
|
throw new Error(`Failed to install dotnet ${exitCode}. ${stdout}`);
|
||||||
}
|
}
|
||||||
|
return this.outputDotnetVersion(stdout);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
outputDotnetVersion(logs) {
|
||||||
|
let resolvedVersion = '';
|
||||||
|
const installedByScriptPattern = /Installed version is (?<version>\d+\.\d+\.\d.*)$/m;
|
||||||
|
const preinstalledOnRunnerPattern = /.NET Core SDK with version '(?<version>\d+\.\d+\.\d.*)'/m;
|
||||||
|
let regExpressions = [
|
||||||
|
installedByScriptPattern,
|
||||||
|
preinstalledOnRunnerPattern
|
||||||
|
];
|
||||||
|
for (let regExp of regExpressions) {
|
||||||
|
if (regExp.test(logs)) {
|
||||||
|
resolvedVersion = logs.match(regExp).groups.version;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return resolvedVersion;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
exports.DotnetCoreInstaller = DotnetCoreInstaller;
|
exports.DotnetCoreInstaller = DotnetCoreInstaller;
|
||||||
DotnetCoreInstaller.installationDirectoryWindows = path_1.default.join(process.env['PROGRAMFILES'] + '', 'dotnet');
|
DotnetCoreInstaller.installationDirectoryWindows = path_1.default.join(process.env['PROGRAMFILES'] + '', 'dotnet');
|
||||||
@ -408,6 +425,7 @@ const core = __importStar(__nccwpck_require__(2186));
|
|||||||
const installer_1 = __nccwpck_require__(1480);
|
const installer_1 = __nccwpck_require__(1480);
|
||||||
const fs = __importStar(__nccwpck_require__(7147));
|
const fs = __importStar(__nccwpck_require__(7147));
|
||||||
const path_1 = __importDefault(__nccwpck_require__(1017));
|
const path_1 = __importDefault(__nccwpck_require__(1017));
|
||||||
|
const semver_1 = __importDefault(__nccwpck_require__(5911));
|
||||||
const auth = __importStar(__nccwpck_require__(8527));
|
const auth = __importStar(__nccwpck_require__(8527));
|
||||||
const qualityOptions = [
|
const qualityOptions = [
|
||||||
'daily',
|
'daily',
|
||||||
@ -429,6 +447,7 @@ function run() {
|
|||||||
// Proxy, auth, (etc) are still set up, even if no version is identified
|
// Proxy, auth, (etc) are still set up, even if no version is identified
|
||||||
//
|
//
|
||||||
const versions = core.getMultilineInput('dotnet-version');
|
const versions = core.getMultilineInput('dotnet-version');
|
||||||
|
let installedDotnetVersions = [];
|
||||||
const globalJsonFileInput = core.getInput('global-json-file');
|
const globalJsonFileInput = core.getInput('global-json-file');
|
||||||
if (globalJsonFileInput) {
|
if (globalJsonFileInput) {
|
||||||
const globalJsonPath = path_1.default.join(process.cwd(), globalJsonFileInput);
|
const globalJsonPath = path_1.default.join(process.cwd(), globalJsonFileInput);
|
||||||
@ -454,7 +473,8 @@ function run() {
|
|||||||
const uniqueVersions = new Set(versions);
|
const uniqueVersions = new Set(versions);
|
||||||
for (const version of uniqueVersions) {
|
for (const version of uniqueVersions) {
|
||||||
dotnetInstaller = new installer_1.DotnetCoreInstaller(version, quality);
|
dotnetInstaller = new installer_1.DotnetCoreInstaller(version, quality);
|
||||||
yield dotnetInstaller.installDotnet();
|
let installedVersion = yield dotnetInstaller.installDotnet();
|
||||||
|
installedDotnetVersions.push(installedVersion);
|
||||||
}
|
}
|
||||||
installer_1.DotnetCoreInstaller.addToPath();
|
installer_1.DotnetCoreInstaller.addToPath();
|
||||||
}
|
}
|
||||||
@ -463,6 +483,9 @@ function run() {
|
|||||||
if (sourceUrl) {
|
if (sourceUrl) {
|
||||||
auth.configAuthentication(sourceUrl, configFile);
|
auth.configAuthentication(sourceUrl, configFile);
|
||||||
}
|
}
|
||||||
|
core.setOutput('dotnet-version', semver_1.default.maxSatisfying(installedDotnetVersions, '*', {
|
||||||
|
includePrerelease: true
|
||||||
|
}));
|
||||||
const matchersPath = path_1.default.join(__dirname, '..', '.github');
|
const matchersPath = path_1.default.join(__dirname, '..', '.github');
|
||||||
core.info(`##[add-matcher]${path_1.default.join(matchersPath, 'csc.json')}`);
|
core.info(`##[add-matcher]${path_1.default.join(matchersPath, 'csc.json')}`);
|
||||||
}
|
}
|
||||||
|
@ -238,5 +238,27 @@ export class DotnetCoreInstaller {
|
|||||||
if (exitCode) {
|
if (exitCode) {
|
||||||
throw new Error(`Failed to install dotnet ${exitCode}. ${stdout}`);
|
throw new Error(`Failed to install dotnet ${exitCode}. ${stdout}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return this.outputDotnetVersion(stdout);
|
||||||
|
}
|
||||||
|
|
||||||
|
private outputDotnetVersion(logs: string): string {
|
||||||
|
let resolvedVersion: string = '';
|
||||||
|
const installedByScriptPattern = /Installed version is (?<version>\d+\.\d+\.\d.*)$/m;
|
||||||
|
const preinstalledOnRunnerPattern = /.NET Core SDK with version '(?<version>\d+\.\d+\.\d.*)'/m;
|
||||||
|
|
||||||
|
let regExpressions: RegExp[] = [
|
||||||
|
installedByScriptPattern,
|
||||||
|
preinstalledOnRunnerPattern
|
||||||
|
];
|
||||||
|
|
||||||
|
for (let regExp of regExpressions) {
|
||||||
|
if (regExp.test(logs)) {
|
||||||
|
resolvedVersion = logs.match(regExp)!.groups!.version;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return resolvedVersion;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ import * as core from '@actions/core';
|
|||||||
import {DotnetCoreInstaller} from './installer';
|
import {DotnetCoreInstaller} from './installer';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
import semver from 'semver';
|
||||||
import * as auth from './authutil';
|
import * as auth from './authutil';
|
||||||
|
|
||||||
const qualityOptions = [
|
const qualityOptions = [
|
||||||
@ -26,6 +27,7 @@ export async function run() {
|
|||||||
// Proxy, auth, (etc) are still set up, even if no version is identified
|
// Proxy, auth, (etc) are still set up, even if no version is identified
|
||||||
//
|
//
|
||||||
const versions = core.getMultilineInput('dotnet-version');
|
const versions = core.getMultilineInput('dotnet-version');
|
||||||
|
let installedDotnetVersions: string[] = [];
|
||||||
|
|
||||||
const globalJsonFileInput = core.getInput('global-json-file');
|
const globalJsonFileInput = core.getInput('global-json-file');
|
||||||
if (globalJsonFileInput) {
|
if (globalJsonFileInput) {
|
||||||
@ -60,7 +62,8 @@ export async function run() {
|
|||||||
const uniqueVersions = new Set<string>(versions);
|
const uniqueVersions = new Set<string>(versions);
|
||||||
for (const version of uniqueVersions) {
|
for (const version of uniqueVersions) {
|
||||||
dotnetInstaller = new DotnetCoreInstaller(version, quality);
|
dotnetInstaller = new DotnetCoreInstaller(version, quality);
|
||||||
await dotnetInstaller.installDotnet();
|
let installedVersion = await dotnetInstaller.installDotnet();
|
||||||
|
installedDotnetVersions.push(installedVersion);
|
||||||
}
|
}
|
||||||
DotnetCoreInstaller.addToPath();
|
DotnetCoreInstaller.addToPath();
|
||||||
}
|
}
|
||||||
@ -71,6 +74,13 @@ export async function run() {
|
|||||||
auth.configAuthentication(sourceUrl, configFile);
|
auth.configAuthentication(sourceUrl, configFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
core.setOutput(
|
||||||
|
'dotnet-version',
|
||||||
|
semver.maxSatisfying(installedDotnetVersions, '*', {
|
||||||
|
includePrerelease: true
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
const matchersPath = path.join(__dirname, '..', '.github');
|
const matchersPath = path.join(__dirname, '..', '.github');
|
||||||
core.info(`##[add-matcher]${path.join(matchersPath, 'csc.json')}`);
|
core.info(`##[add-matcher]${path.join(matchersPath, 'csc.json')}`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user