From b51a6a673a443b4f23a75b06d04619246188feae Mon Sep 17 00:00:00 2001 From: max143672 Date: Thu, 12 Sep 2024 18:56:55 +0300 Subject: [PATCH] cache binary --- .github/workflows/anchor-cli.yml | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/.github/workflows/anchor-cli.yml b/.github/workflows/anchor-cli.yml index 32c715c..7d05a10 100644 --- a/.github/workflows/anchor-cli.yml +++ b/.github/workflows/anchor-cli.yml @@ -46,15 +46,6 @@ jobs: packages: pkg-config build-essential libudev-dev musl-tools version: 1.0 - - name: Install Rust - uses: dtolnay/rust-toolchain@master - with: - toolchain: ${{ github.event.inputs.rust_version }} - targets: ${{ github.event.inputs.target }} - - - name: Run sccache-cache - uses: mozilla-actions/sccache-action@v0.0.5 - - name: Set version or rev id: set_version run: | @@ -64,7 +55,23 @@ jobs: echo "version_or_rev=${{ github.event.inputs.anchor_version }}" >> $GITHUB_OUTPUT fi + - name: Install Rust + uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ github.event.inputs.rust_version }} + targets: ${{ github.event.inputs.target }} + + - name: Run sccache-cache + uses: mozilla-actions/sccache-action@v0.0.5 + + - name: Restore cached Anchor CLI binary + id: cache-anchor-restore + uses: actions/cache/restore@v4 + with: + path: ~/.cargo/bin/anchor-${{ steps.set_version.outputs.version_or_rev }}-${{ github.event.inputs.target }} + key: ${{ runner.os }}-anchor-${{ steps.set_version.outputs.version_or_rev }}-${{ github.event.inputs.target }}-${{ github.event.inputs.rust_version }} - name: Build Anchor CLI + if: steps.cache-anchor-restore.outputs.cache-hit != 'true' run: | if [ -n "${{ github.event.inputs.rev }}" ]; then RUSTFLAGS='-C target-feature=+crt-static' cargo install --git https://github.com/coral-xyz/anchor --rev ${{ github.event.inputs.rev }} --target ${{ github.event.inputs.target }} anchor-cli --locked @@ -74,6 +81,13 @@ jobs: fi mv ~/.cargo/bin/anchor ~/.cargo/bin/anchor-${{ steps.set_version.outputs.version_or_rev }}-${{ github.event.inputs.target }} + - name: Save Anchor CLI binary cache + if: steps.cache-anchor-restore.outputs.cache-hit != 'true' + uses: actions/cache/save@v4 + with: + path: ~/.cargo/bin/anchor-${{ steps.set_version.outputs.version_or_rev }}-${{ github.event.inputs.target }} + key: ${{ runner.os }}-anchor-${{ steps.set_version.outputs.version_or_rev }}-${{ github.event.inputs.target }}-${{ github.event.inputs.rust_version }} + - name: Release uses: softprops/action-gh-release@v1 with: