Skip to content

Commit

Permalink
cache binary
Browse files Browse the repository at this point in the history
  • Loading branch information
biryukovmaxim committed Sep 12, 2024
1 parent 4cae613 commit b51a6a6
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions .github/workflows/anchor-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]

- name: Set version or rev
id: set_version
run: |
Expand All @@ -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/[email protected]

- 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
Expand All @@ -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:
Expand Down

0 comments on commit b51a6a6

Please sign in to comment.