rustc-hash output

This commit is contained in:
svartalf 2020-01-24 19:13:54 +03:00
parent 661772c5dc
commit 1531bd3837
3 changed files with 14 additions and 10 deletions

View File

@ -52,11 +52,15 @@ See [additional recipes here](https://github.com/actions-rs/meta).
Installed `rustc`, `cargo` and `rustup` versions can be fetched from the Action outputs:
| Name | Example |
| -------- | ------------------------------- |
| `rustc` | `1.40.0 (73528e339 2019-12-16)` |
| `cargo` | `1.40.0 (bc8e4c8be 2019-11-22)` |
| `rustup` | `1.21.1 (7832b2ebe 2019-12-20)` |
| Name | Description | Example |
| ------------ | --------------------- | ------------------------------- |
| `rustc` | Rustc version | `1.40.0 (73528e339 2019-12-16)` |
| `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)` |
Note: `rustc-hash` output value can be used with [actions/cache](https://github.com/actions/cache) Action
to store cache for different Rust versions, as it is unique across different Rust versions and builds (including `nightly`).
## Profiles

2
dist/index.js vendored

File diff suppressed because one or more lines are too long

View File

@ -21,7 +21,7 @@ async function rustc(): Promise<void> {
const version = parse(stdout);
core.setOutput('rustc', version.long);
// core.setOutput('rustc_short', version.short);
core.setOutput('rustc-hash', version.hash);
}
/**
@ -44,20 +44,20 @@ async function rustup(): Promise<void> {
}
interface Version {
short: string,
long: string,
hash: string,
}
function parse(stdout: string): Version {
stdout = stdout.trim();
const matches = stdout.match(/\S+\s((\S+)\s\(.+\))/m);
const matches = stdout.match(/\S+\s((\S+)\s\((\S+)\s(\S+)\))/m);
if (matches == null) {
throw new Error(`Unable to parse version from the "${stdout}" string`);
}
return {
short: matches[2],
long: matches[1],
hash: matches[3],
}
}