Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

Commit

Permalink
Release v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
svartalf committed Sep 15, 2019
1 parent c945514 commit 8e603f3
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 31 deletions.
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
max_line_length = 80
indent_size = 4

[*.yml]
indent_size = 2
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# `rustup toolchain` Action

![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)
[![Gitter](https://badges.gitter.im/actions-rs/community.svg)](https://gitter.im/actions-rs/community)

This GitHub Action installs [Rust toolchain](https://github.com/rust-lang/rustup.rs#toolchain-specification).
Expand All @@ -20,7 +21,7 @@ jobs:
steps:
- uses: actions/checkout@master
- name: Install nightly
uses: actions-rs/toolchain@1
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
Expand All @@ -34,7 +35,14 @@ jobs:
* `default`: Set installed toolchain as default (executes `rustup toolchain default {TOOLCHAIN}`)
* `override`: Set installed toolchain as an override for current directory

## Components

If you are going to install `clippy`, `rustfmt` or any other [rustup component](https://rust-lang.github.io/rustup-components-history/),
it might not be available in latest `nightly` build;
check out the [`actions-rs/components-nightly`](https://github.com/actions-rs/components-nightly) Action,
which makes this process much easier.

## Notes

As `rustup` is not installed by default for macOS and Windows images at the moment (2019-09-13),
this Action will try its best to install it before any other operations.
As `rustup` is not installed by default for [macOS environments](https://help.github.com/en/articles/virtual-environments-for-github-actions)
at the moment (2019-09-13), this Action will try its best to install it before any other operations.
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'rustup toolchain'
name: 'rust-toolchain'
description: 'Install the Rust toolchain'
author: 'actions-rs team'
branding:
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rustup-toolchain",
"version": "0.1.0",
"name": "rust-toolchain",
"version": "1.0.0",
"private": false,
"description": "Install the Rust toolchain",
"main": "lib/main.js",
Expand Down
40 changes: 16 additions & 24 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ async function get_rustup(toolchain: string, target?: string): Promise<string> {
case 'darwin':
case 'linux': // Should be installed already, but just in case
const rustupSh = await downloadRustInit('https://sh.rustup.rs', 'rustup-init.sh');
await do_exec(rustupSh, args);
await exec.exec(rustupSh, args);
break;

case 'win32':
const rustupExe = await downloadRustInit('http://win.rustup.rs', 'rustup-init.exe');
await do_exec(rustupExe, args);
await exec.exec(rustupExe, args);
break;

default:
Expand All @@ -72,39 +72,31 @@ async function get_rustup(toolchain: string, target?: string): Promise<string> {
return 'rustup';
}

async function do_exec(program: string, args: string[]): Promise<number> {
try {
return await exec.exec(program, args);
} catch (error) {
core.setFailed(error.message);
throw error;
}
}

async function run() {
let opts;
try {
opts = args.toolchain_args();
} catch (error) {
core.setFailed(error.message);
return;
}

const opts = args.toolchain_args();
const rustup = await get_rustup(opts.name, opts.target);

await do_exec(rustup, ['toolchain', 'install', opts.name]);
await exec.exec(rustup, ['toolchain', 'install', opts.name]);

if (opts.default) {
await do_exec(rustup, ['default', opts.name]);
await exec.exec(rustup, ['default', opts.name]);
}

if (opts.override) {
await do_exec(rustup, ['override', 'set', opts.name]);
await exec.exec(rustup, ['override', 'set', opts.name]);
}

if (opts.target) {
await do_exec(rustup, ['target', 'add', '--toolchain', opts.name, opts.target]);
await exec.exec(rustup, ['target', 'add', '--toolchain', opts.name, opts.target]);
}
}

async function main() {
try {
await run();
} catch (error) {
core.setFailed(error.message);
}
}

run();
main();

0 comments on commit 8e603f3

Please sign in to comment.