gh install - Github client extension
TLDR
See the code here
Background
gh install
is a small Github client (gh
) extension that lets you install Github release binaries for any public Githib repository. It runs as a non-interactive command by default, but you can run it with interactive terminal prompts by specifying the -i
flag.
It is useful for installing releases that are not distributed through common package managers (like brew
or apt
)
It should be able to deal with release assets that are:
- compressed single or multiple binaries
- uncompressed binaries
- rpm or apk files
Installation
Run:
gh extension install maratoid/gh-install
Help
gh install --help
Install binaries for a Github repository release interactively or non-interactively.
Intended for quickly installing release binaries for projects that do not distribute
using Homebrew or other package managers.
Usage:
gh install owner/repository [flags]
Flags:
-b, --binary string install release asset archive binary name. If empty, '--binary-regex' is used.
--binary-regex string lookup regexp for release asset archive binary. If empty, repository name is used.
-d, --download string name for release asset to download. If empty, '--download-regex' is used.
--download-regex string lookup regexp for release asset to download. (default "^.*(?:arm64.+darwin|darwin.+arm64)+.*$")
-h, --help help for gh
-i, --interactive Use interactive installation. If true, all other flags are ignored
-j, --json JSON output
-t, --tag string release tag (version) to install. (default "latest")
-v, --version version for gh
Below flags only make sense when -i
is NOT set:
-t, --tag
- Look for release assets under this version/tag. If not specified, assumelatest
Github release-d, --download
- File name of release asset to download under chosen version/tag. If not specified,--download-regex
value is used.--download-regex
- Regular expression for matching the release asset to download under chosen version/tag. Default value changes depending on your hardware/os. For example, on Apple silicone it will be^.*(?:arm64.+darwin|darwin.+arm64)+.*$
-b, --binary
- If downloaded asset is an archive, install this binary name from the archive. If not specified,--binary-regex
is used.--binary-regex
- If downloaded asset is an archive, use this regular expression for selecting the binary to install. Default is the name of target repository. For example forhelmfile/vals
it will be^vals$
-j, --json
- Output results in JSON format
Other:
-i, --interactive
- Use interactive prompts instead of relying on-tdb
flags. If true, all other flags are ignored
Example
Install latest release from https://github.com/helmfile/vals
$ gh install helmfile/vals
Release Asset Binaries Matcher vals
Release Asset Binaries Matches [vals]
Release Versions Matches [v0.37.8]
Install Dir /Users/maratoid/.local/bin
Release Assets Matches [vals_0.37.8_darwin_arm64.tar.gz]
Target Repository helmfile/vals
Release Asset Binaries Multiple false
Asset Installed Binaries vals (compressed)
Release Versions Multiple false
Release Assets Matcher ^.*(?:arm64.+darwin|darwin.+arm64)+.*$
Release Assets Multiple false
Download Dir /var/folders/pj/dfbt8l6s2cqgs7c_x2fxgyj00000gn/T/4284942397
Gh Stdout
Install latest release from https://github.com/helmfile/vals, output JSON
$ gh install helmfile/vals -j
{
"asset_installed_binaries": {
"vals": "compressed"
},
"download_dir": "/var/folders/pj/dfbt8l6s2cqgs7c_x2fxgyj00000gn/T/3649521499",
"gh_stdout": "",
"install_dir": "/Users/maratoid/.local/bin",
"release_asset_binaries_matcher": "vals",
"release_asset_binaries_matches": ["vals"],
"release_asset_binaries_multiple": false,
"release_assets_matcher": "^.*(?:arm64.+darwin|darwin.+arm64)+.*$",
"release_assets_matches": ["vals_0.37.8_darwin_arm64.tar.gz"],
"release_assets_multiple": false,
"release_versions_matcher": "v0.37.8",
"release_versions_matches": ["v0.37.8"],
"release_versions_multiple": false,
"target_repository": "helmfile/vals"
}
Error - no matching binary in downloaded release asset
$ gh install helmfile/vals -b "f00bar" -j
{
...
"error": "no release asset binaries named 'f00bar' found",
...
}
Error - no matching release asset
$ gh install helmfile/vals -d "f00bar" -j
{
"error": "no release assets named 'f00bar' found",
...
}
Interactive prompts
$ gh install helmfile/vals -i
Use <Enter> to select, '/' to search and '↓ ↑ → ←' to navigate.
? Please select helmfile/vals release tag:
→ v0.37.8
v0.37.7
v0.37.6
v0.37.5
v0.37.4
v0.37.3
v0.37.2
v0.37.1
v0.37.0
↓ v0.36.0