GitHub

HTTP Helpers

Functions for HTTP requests and GitHub API access, useful for update checking and downloading.

Overview

Timeout defaults to 30 seconds (configurable via RECIPE_HTTP_TIMEOUT env var). For downloading files, see Acquire Helpers.

http_get

Fetch content from a URL. Returns the response body as a string.

let page = http_get("https://api.example.com/version");

github_latest_release

Get the latest release version from a GitHub repository. Strips the v prefix automatically.

fn check_update() {
    let latest = github_latest_release("BurntSushi/ripgrep");
    // Returns "14.1.0" (not "v14.1.0")
    if latest != ctx.version {
        latest
    } else {
        ()
    }
}

github_latest_tag

Get the latest tag from a GitHub repository. Strips the v prefix automatically. Useful for projects that use tags instead of releases.

let latest = github_latest_tag("torvalds/linux");
// Returns "6.7" for tag "v6.7"

github_download_release

Download a release asset from GitHub. Takes the repo, version, and a glob pattern for the asset name. Returns the downloaded file path. See Acquire Helpers for more details.

let archive = github_download_release(
    "BurntSushi/ripgrep",
    "14.1.0",
    "ripgrep-*-x86_64-unknown-linux-musl.tar.gz"
);

parse_version

Strip common prefixes from version strings (v, release-, version-).

parse_version("v1.0.0");        // "1.0.0"
parse_version("release-2.0");   // "2.0"
parse_version("version-3.1");   // "3.1"