Install rustup
only on MacOS
This commit is contained in:
parent
cd0149be15
commit
7b201a613e
@ -16,6 +16,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const core = __importStar(require("@actions/core"));
|
const core = __importStar(require("@actions/core"));
|
||||||
|
const exec = __importStar(require("@actions/exec"));
|
||||||
const rustup = __importStar(require("./rustup"));
|
const rustup = __importStar(require("./rustup"));
|
||||||
function run() {
|
function run() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
@ -23,6 +24,7 @@ function run() {
|
|||||||
const version = core.getInput('rust-version');
|
const version = core.getInput('rust-version');
|
||||||
if (version) {
|
if (version) {
|
||||||
yield rustup.install(version);
|
yield rustup.install(version);
|
||||||
|
exec.exec('rustup', ['default', version]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
|
@ -17,24 +17,18 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const core = __importStar(require("@actions/core"));
|
const core = __importStar(require("@actions/core"));
|
||||||
const exec = __importStar(require("@actions/exec"));
|
const exec = __importStar(require("@actions/exec"));
|
||||||
const io = __importStar(require("@actions/io"));
|
|
||||||
const toolCache = __importStar(require("@actions/tool-cache"));
|
const toolCache = __importStar(require("@actions/tool-cache"));
|
||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
const os = __importStar(require("os"));
|
const os = __importStar(require("os"));
|
||||||
const fs_1 = require("fs");
|
const fs_1 = require("fs");
|
||||||
let osPlat = os.platform();
|
|
||||||
let osArch = os.arch();
|
|
||||||
let tempDirectory = process.env['RUNNER_TEMPDIRECTORY'] || '';
|
let tempDirectory = process.env['RUNNER_TEMPDIRECTORY'] || '';
|
||||||
const WINDOWS = osPlat == 'win32';
|
|
||||||
function install(version) {
|
function install(version) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let toolPath = toolCache.find('rust', version);
|
if (os.platform() == 'darwin') {
|
||||||
if (!toolPath) {
|
let toolPath = yield acquireRust(version);
|
||||||
toolPath = yield acquireRust(version);
|
|
||||||
core.debug('Rust toolchain is cached under ' + toolPath);
|
core.debug('Rust toolchain is cached under ' + toolPath);
|
||||||
|
core.addPath(path.join(toolPath, 'bin'));
|
||||||
}
|
}
|
||||||
toolPath = path.join(toolPath, 'bin');
|
|
||||||
core.addPath(toolPath);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.install = install;
|
exports.install = install;
|
||||||
@ -42,42 +36,15 @@ function acquireRust(version) {
|
|||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let script;
|
let script;
|
||||||
try {
|
try {
|
||||||
script = yield toolCache.downloadTool(rustupUrl());
|
script = yield toolCache.downloadTool("https://sh.rustup.rs");
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
core.debug(error);
|
core.debug(error);
|
||||||
throw `Failed to download rustup: ${error}`;
|
throw `Failed to download rustup: ${error}`;
|
||||||
}
|
}
|
||||||
if (WINDOWS) {
|
fs_1.chmodSync(script, '777');
|
||||||
yield io.cp(script, script + '.exe');
|
yield exec.exec(`"${script}"`, ['-y', '--default-toolchain', 'none']);
|
||||||
script += '.exe';
|
let cargo = path.join(process.env['HOME'] || '', '.cargo');
|
||||||
console.log(yield io.which('rustup', true));
|
return yield toolCache.cacheDir(cargo, 'rust', version);
|
||||||
yield exec.exec(`"${script}"`, [
|
|
||||||
'-y',
|
|
||||||
'--default-toolchain',
|
|
||||||
'none',
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
fs_1.chmodSync(script, '777');
|
|
||||||
yield exec.exec(`"${script}"`, ['-y', '--default-toolchain', version]);
|
|
||||||
}
|
|
||||||
return yield toolCache.cacheDir(binRoot(), 'rust', version);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function rustupUrl() {
|
|
||||||
if (WINDOWS) {
|
|
||||||
return "https://win.rustup.rs";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return "https://sh.rustup.rs";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function binRoot() {
|
|
||||||
if (WINDOWS) {
|
|
||||||
return path.join(process.env['USERPROFILE'] || '', '.cargo');
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return path.join(process.env['HOME'] || '', '.cargo');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
|
import * as exec from '@actions/exec';
|
||||||
import * as rustup from './rustup';
|
import * as rustup from './rustup';
|
||||||
import * as os from 'os';
|
import * as os from 'os';
|
||||||
|
|
||||||
@ -8,6 +9,8 @@ async function run() {
|
|||||||
|
|
||||||
if(version) {
|
if(version) {
|
||||||
await rustup.install(version);
|
await rustup.install(version);
|
||||||
|
|
||||||
|
exec.exec('rustup', ['default', version]);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
|
@ -6,68 +6,32 @@ import * as path from 'path';
|
|||||||
import * as os from 'os';
|
import * as os from 'os';
|
||||||
import {chmodSync} from 'fs';
|
import {chmodSync} from 'fs';
|
||||||
|
|
||||||
let osPlat: string = os.platform();
|
|
||||||
let osArch: string = os.arch();
|
|
||||||
let tempDirectory = process.env['RUNNER_TEMPDIRECTORY'] || '';
|
let tempDirectory = process.env['RUNNER_TEMPDIRECTORY'] || '';
|
||||||
const WINDOWS: boolean = osPlat == 'win32';
|
|
||||||
|
|
||||||
export async function install(version: string) {
|
export async function install(version: string) {
|
||||||
let toolPath = toolCache.find('rust', version);
|
if (os.platform() == 'darwin') {
|
||||||
|
let toolPath = await acquireRust(version);
|
||||||
|
|
||||||
if (!toolPath) {
|
|
||||||
toolPath = await acquireRust(version);
|
|
||||||
core.debug('Rust toolchain is cached under ' + toolPath);
|
core.debug('Rust toolchain is cached under ' + toolPath);
|
||||||
}
|
|
||||||
|
|
||||||
toolPath = path.join(toolPath, 'bin');
|
core.addPath(path.join(toolPath, 'bin'));
|
||||||
core.addPath(toolPath);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function acquireRust(version: string): Promise<string> {
|
async function acquireRust(version: string): Promise<string> {
|
||||||
let script: string;
|
let script: string;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
script = await toolCache.downloadTool(rustupUrl());
|
script = await toolCache.downloadTool("https://sh.rustup.rs");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.debug(error);
|
core.debug(error);
|
||||||
throw `Failed to download rustup: ${error}`;
|
throw `Failed to download rustup: ${error}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(WINDOWS) {
|
chmodSync(script, '777');
|
||||||
await io.cp(script, script + '.exe');
|
await exec.exec(`"${script}"`, ['-y', '--default-toolchain', 'none']);
|
||||||
script += '.exe';
|
|
||||||
|
|
||||||
console.log(await io.which('rustup', true));
|
let cargo = path.join(process.env['HOME'] || '', '.cargo');
|
||||||
|
|
||||||
await exec.exec(
|
return await toolCache.cacheDir(cargo, 'rust', version);
|
||||||
`"${script}"`,
|
|
||||||
[
|
|
||||||
'-y',
|
|
||||||
'--default-toolchain',
|
|
||||||
'none',
|
|
||||||
]
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
chmodSync(script, '777');
|
|
||||||
|
|
||||||
await exec.exec(`"${script}"`, ['-y', '--default-toolchain', version]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return await toolCache.cacheDir(binRoot(), 'rust', version);
|
|
||||||
}
|
|
||||||
|
|
||||||
function rustupUrl(): string {
|
|
||||||
if(WINDOWS) {
|
|
||||||
return "https://win.rustup.rs"
|
|
||||||
} else {
|
|
||||||
return "https://sh.rustup.rs"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function binRoot(): string {
|
|
||||||
if(WINDOWS) {
|
|
||||||
return path.join(process.env['USERPROFILE'] || '', '.cargo');
|
|
||||||
} else {
|
|
||||||
return path.join(process.env['HOME'] || '', '.cargo');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user