From 29a23851405f6fd74e4fdb1746063d7624364bdb Mon Sep 17 00:00:00 2001 From: Jonas Bushart Date: Tue, 19 Jul 2022 19:00:36 +0000 Subject: [PATCH] Better and more verbose version printing and cachekey version. --- CHANGELOG.md | 2 ++ action.yml | 20 ++++++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4962446..e4cdd30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Install rustup if not available in the CI environment. (Linux only) The code is taken from this issue: +* Add rustc version output suitable as a cache key. + This is based on and . ## [1.0.1] - 2022-04-20 diff --git a/action.yml b/action.yml index 608fccf..a816ecd 100644 --- a/action.yml +++ b/action.yml @@ -33,6 +33,9 @@ outputs: rustup-version: description: "Version as reported by `rustup --version`" value: ${{steps.versions.outputs.rustup-version}} + cachekey: + description: A short hash of the rustc version, appropriate for use as a cache key. "20220627a831" + value: ${{steps.versions.outputs.cachekey}} runs: using: composite @@ -60,15 +63,20 @@ runs: rustup toolchain install ${{inputs.toolchain}}${{steps.flags.outputs.targets}}${{steps.flags.outputs.components}} --profile minimal${{steps.flags.outputs.downgrade}} --no-self-update rustup default ${{inputs.toolchain}} shell: bash + - name: Print installed versions id: versions run: | - echo "::set-output name=rustc-version::$(rustc --version)" - rustc --version - echo "::set-output name=cargo-version::$(cargo --version)" - cargo --version - echo "::set-output name=rustup-version::$(rustup --version)" - rustup --version + echo "::set-output name=rustc-version::$(rustc +${{inputs.toolchain}} --version)" + rustc +${{inputs.toolchain}} --version --verbose + echo "::set-output name=cargo-version::$(cargo +${{inputs.toolchain}} --version)" + cargo +${{inputs.toolchain}} --version --verbose + echo "::set-output name=rustup-version::$(rustup +${{inputs.toolchain}} --version)" + rustup +${{inputs.toolchain}} --version + + 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') + HASH=$(rustc +${{inputs.toolchain}} --version --verbose | sed -ne 's/^commit-hash: //p') + echo "::set-output name=cachekey::$(echo $DATE$HASH | head -c12)" shell: bash - name: "Setup Rust Caching"