2019-06-21 20:21:08 +08:00
|
|
|
import * as core from '@actions/core';
|
|
|
|
import * as installer from './installer';
|
2019-08-12 22:51:47 +08:00
|
|
|
import * as fs from 'fs';
|
2019-06-21 21:44:33 +08:00
|
|
|
import * as path from 'path';
|
2019-06-21 20:21:08 +08:00
|
|
|
|
2019-08-13 00:14:43 +08:00
|
|
|
export async function run() {
|
2019-06-21 20:21:08 +08:00
|
|
|
try {
|
|
|
|
//
|
|
|
|
// Version is optional. If supplied, install / use from the tool cache
|
|
|
|
// If not supplied then task is still used to setup proxy, auth, etc...
|
|
|
|
//
|
2019-08-13 00:14:43 +08:00
|
|
|
let version: string = core.getInput('version');
|
2019-08-14 04:05:52 +08:00
|
|
|
if (!version) {
|
|
|
|
version = core.getInput('dotnet-version');
|
|
|
|
}
|
2019-08-12 22:51:47 +08:00
|
|
|
if (!version) {
|
|
|
|
// Try to fall back to global.json
|
2019-08-13 00:14:43 +08:00
|
|
|
core.debug('No version found, trying to find version from global.json');
|
2019-08-12 22:51:47 +08:00
|
|
|
const globalJsonPath = path.join(process.cwd(), 'global.json');
|
|
|
|
if (fs.existsSync(globalJsonPath)) {
|
|
|
|
const globalJson = JSON.parse(
|
|
|
|
fs.readFileSync(globalJsonPath, {encoding: 'utf8'})
|
|
|
|
);
|
|
|
|
if (globalJson.sdk && globalJson.sdk.version) {
|
|
|
|
version = globalJson.sdk.version;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-21 20:21:08 +08:00
|
|
|
if (version) {
|
|
|
|
const dotnetInstaller = new installer.DotnetCoreInstaller(version);
|
|
|
|
await dotnetInstaller.installDotnet();
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: setup proxy from runner proxy config
|
2019-06-21 21:44:33 +08:00
|
|
|
|
|
|
|
const matchersPath = path.join(__dirname, '..', '.github');
|
|
|
|
console.log(`##[add-matcher]${path.join(matchersPath, 'csc.json')}`);
|
2019-06-21 20:21:08 +08:00
|
|
|
} catch (error) {
|
|
|
|
core.setFailed(error.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
run();
|