gh install - Github client extension
Install binaries for a Github repository release.
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 -h
Usage: gh-install <repository> [flags]
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.
Arguments:
<repository> Github repository in OWNER/REPOSITORY_NAME format ($GH_INSTALL_REPOSITORY).
Flags:
-h, --help Show context-sensitive help.
-p, --target-path="/Users/maratoid/.local/bin"
Target installation directory ($GH_INSTALL_TARGET_PATH).
-l, --log-level="info" Log level ($GH_INSTALL_LOG_LEVEL).
-f, --log-format="console" Log output format ($GH_INSTALL_LOG_FORMAT).
--version Show version ($GH_INSTALL_VERSION).
Interactive Mode
-i, --interactive Use interactive installation. If true, all non-log related
flags are ignored ($GH_INSTALL_INTERACTIVE).
--[no-]log-quiet-interactive Quiet log in interactive mode
($GH_INSTALL_LOG_QUIET_INTERACTIVE)
Non-interactive Mode
-v, --release-version="latest" Repository release tag (version) to install
($GH_INSTALL_RELEASE_VERSION).
-a, --release-asset=STRING Name of repository release asset to download.
If not set, --release-asset-regexp is used
($GH_INSTALL_RELEASE_ASSET).
-A, --release-asset-regexp="^.*(?:arm64.+darwin|darwin.+arm64)+.*$"
Regular expression matching release asset to download
($GH_INSTALL_RELEASE_ASSET_REGEXP).
-b, --asset-binaries=ASSET-BINARIES,...
If release asset is an archive - names
of a binaries in the archive to install.
If not set, --install-binary-regexp is used
($GH_INSTALL_ASSET_BINARIES).
-B, --asset-binaries-regexp=STRING If release asset is an archive - regular
expression matching binaries in the archive to
install. If not set, repository name is used
($GH_INSTALL_ASSET_BINARIES_REGEXP).
-t, --target-binaries=KEY=VALUE;...
Rename binaries installed at target path,
"<asset archive binary | asset>=<renamed binary>;..."
($GH_INSTALL_TARGET_BINARIES)
--[no-]target-path-create Create target installation directory if it does not exist
($GH_INSTALL_TARGET_PATH_CREATE).
-o, --target-binaries-overwrite Overwrite target binaries
($GH_INSTALL_TARGET_BINARIES_OVERWRITE).
Example
Install release from https://github.com/charmbracelet/gum
- Use
latestrelease - Download
gum_0.17.0_Darwin_arm64.tar.gzrelease asset - From
gum_0.17.0_Darwin_arm64.tar.gzinstallgumandgum.fish“binaries” - Install
gumasbumandgum.fishasbum.dish - Overwrite
bumandbum.dishif they already exist
$ gh install charmbracelet/gum -a gum_0.17.0_Darwin_arm64.tar.gz -b gum,gum.fish -t "gum=bum;gum.fish=bum.dish" --target-binaries-overwrite
7:37PM INF installing with values release asset binary name regexp=^gum$ release asset binary names=["gum","gum.fish"] release asset name=gum_0.17.0_Darwin_arm64.tar.gz release asset regexp=^.*(?:arm64.+darwin|darwin.+arm64)+.*$ release version=latest renaming binaries={"gum":"bum","gum.fish":"bum.dish"} repository=charmbracelet/gum target path=/Users/maratoid/.local/bin
7:37PM INF getting Github repository releases repository=charmbracelet/gum
7:37PM INF using release v0.17.0 repository=charmbracelet/gum
7:37PM INF getting release assets asset matching name=gum_0.17.0_Darwin_arm64.tar.gz asset matching regexp=^.*(?:arm64.+darwin|darwin.+arm64)+.*$ release id=245136112 repository=charmbracelet/gum
7:37PM INF downloaded release asset download directory=/var/folders/56/mm_0pjwj1qd567_7_t18qdph0000gn/T/3115480104 output= release asset name=gum_0.17.0_Darwin_arm64.tar.gz release id=245136112 release name=v0.17.0 repository=charmbracelet/gum
7:37PM INF getting release asset binaries asset download path=/var/folders/56/mm_0pjwj1qd567_7_t18qdph0000gn/T/3115480104/gum_0.17.0_Darwin_arm64.tar.gz asset matching binary names=["gum","gum.fish"] asset matching binary regexp=^gum$
7:37PM INF processing selected release asset binary downloaded asset=/var/folders/56/mm_0pjwj1qd567_7_t18qdph0000gn/T/3115480104/gum_0.17.0_Darwin_arm64.tar.gz release asset binary=gum.fish release asset name=gum_0.17.0_Darwin_arm64.tar.gz release id=245136112 release name=v0.17.0 repository=charmbracelet/gum
7:37PM INF will install gum_0.17.0_Darwin_arm64/completions/gum.fish to /Users/maratoid/.local/bin/bum.dish
7:37PM INF processing selected release asset binary downloaded asset=/var/folders/56/mm_0pjwj1qd567_7_t18qdph0000gn/T/3115480104/gum_0.17.0_Darwin_arm64.tar.gz release asset binary=gum release asset name=gum_0.17.0_Darwin_arm64.tar.gz release id=245136112 release name=v0.17.0 repository=charmbracelet/gum
7:37PM INF will install gum_0.17.0_Darwin_arm64/gum to /Users/maratoid/.local/bin/bum
Install from https://github.com/helmfile/vals in interactive mode
$ gh install helmfile/vals -i
Please select helmfile/vals release tag [type to search]:
> v0.43.7
v0.43.6
v0.43.5
v0.43.4
v0.43.3