Function download_binary_from_github

Source
pub async fn download_binary_from_github<P>(
    url: &str,
    dir: P,
    bin_name: &str,
) -> Result<PathBuf>
where P: AsRef<Path>,
Expand description

Reusable function to download a release tarball from GitHub and extract an embedded binary to a specified directory

§Arguments

  • url - URL of the GitHub release artifact tarball (Usually in the form of https://github.com///releases/download//.tar.gz)
  • dir - Directory on disk to install the binary into. This will be created if it doesn’t exist
  • bin_name - Name of the binary inside of the tarball, e.g. nats-server or wadm

§Examples

let url = "https://github.com/wasmCloud/wadm/releases/download/v0.4.0-alpha.1/wadm-v0.4.0-alpha.1-linux-amd64.tar.gz";
let res = download_binary_from_github(url, "/tmp/", "wadm").await;
assert!(res.is_ok());
assert!(res.unwrap().to_string_lossy() == "/tmp/wadm");