From be14d004f75cf436277af61cf59d3f547096da36 Mon Sep 17 00:00:00 2001 From: Mogyuchi Date: Fri, 16 Feb 2024 23:07:21 +0900 Subject: [PATCH] ci: saikyou --- .github/actions/rustc-info/action.yml | 24 ++++++++++++++++++++++++ .github/workflows/clippy.yml | 5 +++++ .github/workflows/docker-publish.yml | 5 ++++- 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 .github/actions/rustc-info/action.yml diff --git a/.github/actions/rustc-info/action.yml b/.github/actions/rustc-info/action.yml new file mode 100644 index 000000000..342683cdd --- /dev/null +++ b/.github/actions/rustc-info/action.yml @@ -0,0 +1,24 @@ +# yaml-language-server: $schema=https://json.schemastore.org/github-action.json + +name: rust info +description: get rust info + +outputs: + package-names: + description: package name "foo" + value: ${{steps.cargo.outputs.package-names}} + host: + description: host "x86_64-unknown-linux-gnu" + value: ${{steps.rustc.outputs.host}} + +runs: + using: composite + steps: + - id: cargo + run: | + echo "package-names=$(cargo metadata --no-deps | jq --compact-output '.packages | map(.name)')" >> $GITHUB_OUTPUT + shell: bash + - id: rustc + run: | + echo "host=$(rustc -vV | awk '/host/ { print $2 }')" >> $GITHUB_OUTPUT + shell: bash diff --git a/.github/workflows/clippy.yml b/.github/workflows/clippy.yml index f46c983c9..ed7b9efb5 100644 --- a/.github/workflows/clippy.yml +++ b/.github/workflows/clippy.yml @@ -18,6 +18,11 @@ jobs: with: toolchain: stable components: clippy + - id: rustc + uses: ./.github/actions/rust-info - uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3 + with: + shared-key: ${{ fromJson(steps.rustc.outputs.package-names)[0] }} + key: ${{ steps.rustc.outputs.host }} - name: Run Clippy run: cargo clippy --all-targets --all-features diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 5fa3d1024..0609468af 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -63,8 +63,11 @@ jobs: with: toolchain: stable target: ${{ matrix.target }} + - id: rustc + uses: ./.github/actions/rust-info - uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3 with: + shared-key: ${{ fromJson(steps.rustc.outputs.package-names)[0] }} key: ${{ matrix.target }} - name: Install cross if: ${{ !matrix.os && matrix.use-cross }} @@ -96,7 +99,7 @@ jobs: needs: build permissions: packages: write - runs-on: 'ubuntu-latest' + runs-on: "ubuntu-latest" outputs: image_tags: ${{ steps.meta.outputs.tags }} env: