Fix rustup installation on Windows

This commit is contained in:
Héctor Ramón Jiménez 2019-08-15 22:54:23 +02:00
parent 91aec57b90
commit cd0149be15
5 changed files with 11 additions and 23 deletions

View File

@ -4,7 +4,7 @@ author: 'Héctor Ramón'
inputs: inputs:
rust-version: rust-version:
description: 'The toolchain name, such as stable, nighly, or 1.8.0' description: 'The toolchain name, such as stable, nighly, or 1.8.0'
default: 'stable' default: '1.37.0'
runs: runs:
using: 'node12' using: 'node12'
main: 'lib/main.js' main: 'lib/main.js'

View File

@ -17,12 +17,11 @@ 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 rustup = __importStar(require("./rustup")); const rustup = __importStar(require("./rustup"));
const os = __importStar(require("os"));
function run() { function run() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
try { try {
const version = core.getInput('rust-version'); const version = core.getInput('rust-version');
if (version && os.platform() != 'win32') { if (version) {
yield rustup.install(version); yield rustup.install(version);
} }
} }

View File

@ -35,7 +35,6 @@ function install(version) {
} }
toolPath = path.join(toolPath, 'bin'); toolPath = path.join(toolPath, 'bin');
core.addPath(toolPath); core.addPath(toolPath);
yield exec.exec('rustup', ['update']);
}); });
} }
exports.install = install; exports.install = install;
@ -50,17 +49,13 @@ function acquireRust(version) {
throw `Failed to download rustup: ${error}`; throw `Failed to download rustup: ${error}`;
} }
if (WINDOWS) { if (WINDOWS) {
// TODO: Fix this
// It currently fails with:
// error: 'rustup-init.exe' is not installed for the toolchain 'stable-x86_64-pc-windows-msvc'
yield io.cp(script, script + '.exe'); yield io.cp(script, script + '.exe');
script += '.exe'; script += '.exe';
const powershell = yield io.which('powershell', true); console.log(yield io.which('rustup', true));
yield exec.exec(`"${script}"`, [ yield exec.exec(`"${script}"`, [
'--default-host', '-y',
'gnu',
'--default-toolchain', '--default-toolchain',
version, 'none',
]); ]);
} }
else { else {
@ -72,7 +67,7 @@ function acquireRust(version) {
} }
function rustupUrl() { function rustupUrl() {
if (WINDOWS) { if (WINDOWS) {
return "https://static.rust-lang.org/rustup/dist/x86_64-pc-windows-gnu/rustup-init.exe"; return "https://win.rustup.rs";
} }
else { else {
return "https://sh.rustup.rs"; return "https://sh.rustup.rs";

View File

@ -6,7 +6,7 @@ async function run() {
try { try {
const version = core.getInput('rust-version'); const version = core.getInput('rust-version');
if(version && os.platform() != 'win32') { if(version) {
await rustup.install(version); await rustup.install(version);
} }
} catch (error) { } catch (error) {

View File

@ -21,8 +21,6 @@ export async function install(version: string) {
toolPath = path.join(toolPath, 'bin'); toolPath = path.join(toolPath, 'bin');
core.addPath(toolPath); core.addPath(toolPath);
await exec.exec('rustup', ['update']);
} }
async function acquireRust(version: string): Promise<string> { async function acquireRust(version: string): Promise<string> {
@ -36,21 +34,17 @@ async function acquireRust(version: string): Promise<string> {
} }
if(WINDOWS) { if(WINDOWS) {
// TODO: Fix this
// It currently fails with:
// error: 'rustup-init.exe' is not installed for the toolchain 'stable-x86_64-pc-windows-msvc'
await io.cp(script, script + '.exe'); await io.cp(script, script + '.exe');
script += '.exe'; script += '.exe';
const powershell = await io.which('powershell', true); console.log(await io.which('rustup', true));
await exec.exec( await exec.exec(
`"${script}"`, `"${script}"`,
[ [
'--default-host', '-y',
'gnu',
'--default-toolchain', '--default-toolchain',
version, 'none',
] ]
); );
} else { } else {
@ -64,7 +58,7 @@ async function acquireRust(version: string): Promise<string> {
function rustupUrl(): string { function rustupUrl(): string {
if(WINDOWS) { if(WINDOWS) {
return "https://static.rust-lang.org/rustup/dist/x86_64-pc-windows-gnu/rustup-init.exe" return "https://win.rustup.rs"
} else { } else {
return "https://sh.rustup.rs" return "https://sh.rustup.rs"
} }