2019-08-15 18:12:08 +00:00
|
|
|
import * as core from '@actions/core';
|
|
|
|
import * as exec from '@actions/exec';
|
|
|
|
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-10-27 05:14:57 +00:00
|
|
|
} else {
|
2019-10-27 18:50:05 +00:00
|
|
|
// Update the GitHub managed VM version of rustup
|
2019-10-27 05:14:57 +00:00
|
|
|
// to leverage newer features like "latest latest compatible nightly"
|
|
|
|
await exec.exec('rustup', ['self', 'update']);
|
2019-10-27 18:50:05 +00:00
|
|
|
|
|
|
|
await exec.exec('rustup', ['set', 'profile', 'minimal']);
|
2019-08-15 21:22:17 +00:00
|
|
|
}
|
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');
|
2019-10-15 08:50:49 +00:00
|
|
|
await exec.exec(`"${script}"`, ['-y', '--default-toolchain', 'none', '--profile=minimal']);
|
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
|
|
|
}
|