2021-10-07 22:51:09 -04:00
name : cargo install
author : David Tolnay
description : Fast `cargo install` action using a GitHub-based binary cache
inputs :
crate :
description : Name of crate as published to crates.io
required : true
bin :
description : Name of binary; default = same as crate name
required : false
2025-01-28 19:04:42 -08:00
github_token :
description : Access token for connecting to GitHub API for artifact attestation; normally the ephemeral {{github.token}} or {{secrets.GITHUB_TOKEN}} when used in a GitHub workflow, or a personal access token when run by Act Runner
default : ${{github.token}}
2021-10-07 22:51:09 -04:00
runs :
using : composite
steps :
2024-04-14 10:08:49 -07:00
- name : Check inputs
run : |
echo "crate=${{inputs.crate}}" >> $GITHUB_OUTPUT
echo "bin=${{inputs.bin || inputs.crate}}" >> $GITHUB_OUTPUT
shell : bash
id : inputs
2021-10-07 22:51:09 -04:00
- name : Determine cargo bin directory
2022-10-13 09:35:44 -07:00
run : echo "dir=$(dirname $(which cargo))" >> $GITHUB_OUTPUT
2021-10-07 23:03:25 -04:00
shell : bash
2021-10-07 22:51:09 -04:00
id : cargo
2024-04-14 10:08:49 -07:00
- name : Download ${{steps.inputs.outputs.bin}}
run : curl --output ${{steps.cargo.outputs.dir}}/${{steps.inputs.outputs.bin}} https://github.com/dtolnay/install/releases/download/${{steps.inputs.outputs.crate}}/${{steps.inputs.outputs.bin}} --location --silent --show-error --fail --retry 5
2021-10-07 23:03:25 -04:00
shell : bash
2025-01-26 13:20:09 -08:00
- name : Verify artifact attestation
run : gh attestation verify --owner dtolnay ${{steps.cargo.outputs.dir}}/${{steps.inputs.outputs.bin}}
env :
2025-01-28 19:04:42 -08:00
GH_TOKEN : ${{inputs.github_token}}
2025-01-26 13:20:09 -08:00
shell : bash
2021-10-07 22:51:09 -04:00
- name : Set executable bit
2024-04-14 10:08:49 -07:00
run : chmod +x ${{steps.cargo.outputs.dir}}/${{steps.inputs.outputs.bin}}
2021-10-07 23:03:25 -04:00
shell : bash