Skip to content

Commit 29a2385

Browse files
authored
Better and more verbose version printing and cachekey version.
1 parent 8ba04cb commit 29a2385

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
* Install rustup if not available in the CI environment. (Linux only)
1313
The code is taken from this issue: <https://github.com/dtolnay/rust-toolchain/pull/8>
14+
* Add rustc version output suitable as a cache key.
15+
This is based on <https://github.com/dtolnay/rust-toolchain/pull/20> and <https://github.com/dtolnay/rust-toolchain/pull/17>.
1416

1517
## [1.0.1] - 2022-04-20
1618

action.yml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ outputs:
3333
rustup-version:
3434
description: "Version as reported by `rustup --version`"
3535
value: ${{steps.versions.outputs.rustup-version}}
36+
cachekey:
37+
description: A short hash of the rustc version, appropriate for use as a cache key. "20220627a831"
38+
value: ${{steps.versions.outputs.cachekey}}
3639

3740
runs:
3841
using: composite
@@ -60,15 +63,20 @@ runs:
6063
rustup toolchain install ${{inputs.toolchain}}${{steps.flags.outputs.targets}}${{steps.flags.outputs.components}} --profile minimal${{steps.flags.outputs.downgrade}} --no-self-update
6164
rustup default ${{inputs.toolchain}}
6265
shell: bash
66+
6367
- name: Print installed versions
6468
id: versions
6569
run: |
66-
echo "::set-output name=rustc-version::$(rustc --version)"
67-
rustc --version
68-
echo "::set-output name=cargo-version::$(cargo --version)"
69-
cargo --version
70-
echo "::set-output name=rustup-version::$(rustup --version)"
71-
rustup --version
70+
echo "::set-output name=rustc-version::$(rustc +${{inputs.toolchain}} --version)"
71+
rustc +${{inputs.toolchain}} --version --verbose
72+
echo "::set-output name=cargo-version::$(cargo +${{inputs.toolchain}} --version)"
73+
cargo +${{inputs.toolchain}} --version --verbose
74+
echo "::set-output name=rustup-version::$(rustup +${{inputs.toolchain}} --version)"
75+
rustup +${{inputs.toolchain}} --version
76+
77+
DATE=$(rustc +${{inputs.toolchain}} --version --verbose | sed -ne 's/^commit-date: \(20[0-9][0-9]\)-\([01][0-9]\)-\([0-3][0-9]\)$/\1\2\3/p')
78+
HASH=$(rustc +${{inputs.toolchain}} --version --verbose | sed -ne 's/^commit-hash: //p')
79+
echo "::set-output name=cachekey::$(echo $DATE$HASH | head -c12)"
7280
shell: bash
7381

7482
- name: "Setup Rust Caching"

0 commit comments

Comments
 (0)