2019-08-15 18:12:08 +00:00
|
|
|
import * as core from '@actions/core';
|
|
|
|
import * as exec from '@actions/exec';
|
|
|
|
import * as io from '@actions/io';
|
|
|
|
import * as toolCache from '@actions/tool-cache';
|
|
|
|
import * as path from 'path';
|
|
|
|
import * as os from 'os';
|
|
|
|
import {chmodSync} from 'fs';
|
|
|
|
|
|
|
|
let tempDirectory = process.env['RUNNER_TEMPDIRECTORY'] || '';
|
|
|
|
|
2019-08-16 00:16:04 +00:00
|
|
|
export async function install() {
|
2019-08-16 01:16:52 +00:00
|
|
|
// `rustup` is already installed on Linux and Windows platforms
|
2019-08-15 21:22:17 +00:00
|
|
|
if (os.platform() == 'darwin') {
|
2019-08-16 00:16:04 +00:00
|
|
|
let toolPath = await installOnUnix();
|
2019-08-15 18:12:08 +00:00
|
|
|
|
2019-08-16 00:16:04 +00:00
|
|
|
core.debug('rustup is located under: ' + toolPath);
|
2019-08-15 21:22:17 +00:00
|
|
|
core.addPath(path.join(toolPath, 'bin'));
|
|
|
|
}
|
2019-08-15 18:12:08 +00:00
|
|
|
}
|
|
|
|
|
2019-08-16 00:16:04 +00:00
|
|
|
async function installOnUnix(): Promise<string> {
|
|
|
|
let script = await toolCache.downloadTool("https://sh.rustup.rs");
|
2019-08-15 18:12:08 +00:00
|
|
|
|
2019-08-15 21:22:17 +00:00
|
|
|
chmodSync(script, '777');
|
|
|
|
await exec.exec(`"${script}"`, ['-y', '--default-toolchain', 'none']);
|
2019-08-15 18:12:08 +00:00
|
|
|
|
2019-08-16 00:16:04 +00:00
|
|
|
return path.join(process.env['HOME'] || '', '.cargo');
|
2019-08-15 18:12:08 +00:00
|
|
|
}
|