|
| 1 | +name: 'Setup Rust Environment' |
| 2 | +description: 'Checkout, setup Rust, cache, and cargo-make' |
| 3 | +inputs: |
| 4 | + fetch-tag: |
| 5 | + description: 'Whether to fetch tag with --deepen=1' |
| 6 | + default: 'false' |
| 7 | + rust-targets: |
| 8 | + description: 'Additional Rust targets to add (space-separated)' |
| 9 | + default: '' |
| 10 | + use-cache: |
| 11 | + description: 'Whether to use Swatinem/rust-cache' |
| 12 | + default: 'true' |
| 13 | + cache-prefix-key: |
| 14 | + description: 'Rust cache prefix key' |
| 15 | + default: 'v4-rust' |
| 16 | + cache-shared-key: |
| 17 | + description: 'Rust cache shared key' |
| 18 | + default: 'debug' |
| 19 | + cache-save-if: |
| 20 | + description: 'Whether to save rust cache' |
| 21 | + default: 'false' |
| 22 | + install-cargo-make: |
| 23 | + description: 'Whether to install cargo-make' |
| 24 | + default: 'true' |
| 25 | + install-cargo-binstall: |
| 26 | + description: 'Whether to install cargo-binstall' |
| 27 | + default: 'false' |
| 28 | +runs: |
| 29 | + using: 'composite' |
| 30 | + steps: |
| 31 | + - name: Fetch tag |
| 32 | + if: inputs.fetch-tag == 'true' |
| 33 | + shell: bash |
| 34 | + run: git fetch origin --deepen=1 |
| 35 | + - name: Setup Rust |
| 36 | + shell: bash |
| 37 | + run: | |
| 38 | + rustup update stable --no-self-update && rustup default stable |
| 39 | + for target in ${{ inputs.rust-targets }}; do |
| 40 | + rustup target add "$target" |
| 41 | + done |
| 42 | + - name: Setup Rust cache |
| 43 | + if: inputs.use-cache == 'true' |
| 44 | + uses: Swatinem/rust-cache@v2 |
| 45 | + with: |
| 46 | + prefix-key: ${{ inputs.cache-prefix-key }} |
| 47 | + shared-key: ${{ inputs.cache-shared-key }} |
| 48 | + cache-all-crates: true |
| 49 | + save-if: ${{ inputs.cache-save-if }} |
| 50 | + - name: Install cargo-make |
| 51 | + if: inputs.install-cargo-make == 'true' |
| 52 | + uses: davidB/rust-cargo-make@v1 |
| 53 | + - name: Install cargo-binstall |
| 54 | + if: inputs.install-cargo-binstall == 'true' |
| 55 | + uses: cargo-bins/cargo-binstall@main |
0 commit comments