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.5
Browse files Browse the repository at this point in the history
  • Loading branch information
svartalf committed Jan 26, 2020
1 parent 402d025 commit 23cd109
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 17 deletions.
22 changes: 20 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,30 @@ jobs:
- run: npm run test

install_stable:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
- macOS-latest
- windows-latest
steps:
- uses: actions/checkout@v1
- uses: ./
- id: toolchain
uses: ./
with:
toolchain: stable
- name: Test toolchain outputs
env:
RUSTC: ${{ steps.toolchain.outputs.rustc }}
RUSTC_HASH: ${{ steps.toolchain.outputs.rustc_hash }}
CARGO: ${{ steps.toolchain.outputs.cargo }}
RUSTUP: ${{ steps.toolchain.outputs.rustup }}
run: |
echo $RUSTC
echo $RUSTC_HASH
echo $CARGO
echo $RUSTUP
install_nightly:
runs-on: ubuntu-latest
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.0.5] - 2020-01-26

### Fixed

- `rustup` version parser does not fail Action execution on `macOS-latest` VM images anymore

## [1.0.4] - 2020-01-26

### Added
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Installed `rustc`, `cargo` and `rustup` versions can be fetched from the Action
| Name | Description | Example |
| ------------ | --------------------- | ------------------------------- |
| `rustc` | Rustc version | `1.40.0 (73528e339 2019-12-16)` |
| `rustc-hash` | Rustc version hash | `73528e339` |
| `rustc_hash` | Rustc version hash | `73528e339` |
| `cargo` | Cargo version | `1.40.0 (bc8e4c8be 2019-11-22)` |
| `rustup` | rustup version | `1.21.1 (7832b2ebe 2019-12-20)` |

Expand Down
10 changes: 10 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ inputs:
description: Comma-separated list of components to be additionally installed for a new toolchain
required: false

outputs:
rustc:
description: Installed Rustc version
rustc_hash:
description: Installed Rustc version hash, can be used for caching purposes
cargo:
description: Installed Cargo version
rustup:
description: Installed rustup version

runs:
using: 'node12'
main: 'dist/index.js'
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rust-toolchain",
"version": "1.0.4",
"version": "1.0.5",
"private": false,
"description": "Install the Rust toolchain",
"main": "lib/main.js",
Expand Down
53 changes: 42 additions & 11 deletions src/versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,37 +18,57 @@ export async function gatherInstalledVersions(): Promise<void> {
*/
async function rustc(): Promise<void> {
const stdout = await getStdout('rustc', ['-V']);
const version = parse(stdout);
try {
const version = parseFull(stdout);

core.setOutput('rustc', version.long);
core.setOutput('rustc-hash', version.hash);
core.setOutput('rustc', version.long);
core.setOutput('rustc_hash', version.hash);
} catch(e) {
core.warning(e);
core.setOutput('rustc', parseShort(stdout));
}
}

/**
* Fetch currently used `cargo` version
*/
async function cargo(): Promise<void> {
const stdout = await getStdout('cargo', ['-V']);
const version = parse(stdout);
try {
const version = parseFull(stdout);

core.setOutput('cargo', version.long);
// core.setOutput('cargo_short', version.short);
core.setOutput('cargo', version.long);
} catch(e) {
core.setOutput('cargo', parseShort(stdout));
}
}

async function rustup(): Promise<void> {
const stdout = await getStdout('rustup', ['-V']);
const version = parse(stdout);

core.setOutput('rustup', version.long);
// core.setOutput('rustup_short', version.short);
try {
const version = parseFull(stdout);
core.setOutput('rustup', version.long);
} catch(e) {
core.setOutput('rustup', parseShort(stdout));
}
}

interface Version {
long: string,
hash: string,
}

function parse(stdout: string): Version {
/**
* Try to parse the version parts and return them.
*
* It is important to note that some components are not providing
* all the expected information, ex. `rustup` on `macOS-latest` VM image
* does not has the hash in the version string,
* so this function might throw an error.
*
* As a fallback, `parseShort` function can be used.
*/
function parseFull(stdout: string): Version {
stdout = stdout.trim();
const matches = stdout.match(/\S+\s((\S+)\s\((\S+)\s(\S+)\))/m);
if (matches == null) {
Expand All @@ -61,6 +81,17 @@ function parse(stdout: string): Version {
}
}

function parseShort(stdout: string): string {
stdout = stdout.trim();
const matches = stdout.match(/\S+\s(.+)/m);
if (matches == null) {
core.warning(`Unable to determine version from the "${stdout}" string`);
return '';
} else {
return matches[1];
}
}

async function getStdout(exe: string, args: string[], options?: {}): Promise<string> {
let stdout = '';
const resOptions = Object.assign({}, options, {
Expand Down

0 comments on commit 23cd109

Please sign in to comment.