From cd0149be15d8b62d3d365fcf5a00d382f4ff2cee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Thu, 15 Aug 2019 22:54:23 +0200 Subject: [PATCH] Fix `rustup` installation on Windows --- action.yml | 2 +- lib/main.js | 3 +-- lib/rustup.js | 13 ++++--------- src/main.ts | 2 +- src/rustup.ts | 14 ++++---------- 5 files changed, 11 insertions(+), 23 deletions(-) diff --git a/action.yml b/action.yml index 4f7cc69..7ca9ea0 100644 --- a/action.yml +++ b/action.yml @@ -4,7 +4,7 @@ author: 'Héctor Ramón' inputs: rust-version: description: 'The toolchain name, such as stable, nighly, or 1.8.0' - default: 'stable' + default: '1.37.0' runs: using: 'node12' main: 'lib/main.js' diff --git a/lib/main.js b/lib/main.js index 8d23233..3e0c1cc 100644 --- a/lib/main.js +++ b/lib/main.js @@ -17,12 +17,11 @@ var __importStar = (this && this.__importStar) || function (mod) { Object.defineProperty(exports, "__esModule", { value: true }); const core = __importStar(require("@actions/core")); const rustup = __importStar(require("./rustup")); -const os = __importStar(require("os")); function run() { return __awaiter(this, void 0, void 0, function* () { try { const version = core.getInput('rust-version'); - if (version && os.platform() != 'win32') { + if (version) { yield rustup.install(version); } } diff --git a/lib/rustup.js b/lib/rustup.js index a11c348..93ee520 100644 --- a/lib/rustup.js +++ b/lib/rustup.js @@ -35,7 +35,6 @@ function install(version) { } toolPath = path.join(toolPath, 'bin'); core.addPath(toolPath); - yield exec.exec('rustup', ['update']); }); } exports.install = install; @@ -50,17 +49,13 @@ function acquireRust(version) { throw `Failed to download rustup: ${error}`; } 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'); script += '.exe'; - const powershell = yield io.which('powershell', true); + console.log(yield io.which('rustup', true)); yield exec.exec(`"${script}"`, [ - '--default-host', - 'gnu', + '-y', '--default-toolchain', - version, + 'none', ]); } else { @@ -72,7 +67,7 @@ function acquireRust(version) { } function rustupUrl() { if (WINDOWS) { - return "https://static.rust-lang.org/rustup/dist/x86_64-pc-windows-gnu/rustup-init.exe"; + return "https://win.rustup.rs"; } else { return "https://sh.rustup.rs"; diff --git a/src/main.ts b/src/main.ts index 6eaf68f..486c14e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -6,7 +6,7 @@ async function run() { try { const version = core.getInput('rust-version'); - if(version && os.platform() != 'win32') { + if(version) { await rustup.install(version); } } catch (error) { diff --git a/src/rustup.ts b/src/rustup.ts index 1881878..023d41a 100644 --- a/src/rustup.ts +++ b/src/rustup.ts @@ -21,8 +21,6 @@ export async function install(version: string) { toolPath = path.join(toolPath, 'bin'); core.addPath(toolPath); - - await exec.exec('rustup', ['update']); } async function acquireRust(version: string): Promise { @@ -36,21 +34,17 @@ async function acquireRust(version: string): Promise { } 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'); script += '.exe'; - const powershell = await io.which('powershell', true); + console.log(await io.which('rustup', true)); await exec.exec( `"${script}"`, [ - '--default-host', - 'gnu', + '-y', '--default-toolchain', - version, + 'none', ] ); } else { @@ -64,7 +58,7 @@ async function acquireRust(version: string): Promise { function rustupUrl(): string { if(WINDOWS) { - return "https://static.rust-lang.org/rustup/dist/x86_64-pc-windows-gnu/rustup-init.exe" + return "https://win.rustup.rs" } else { return "https://sh.rustup.rs" }