コンテンツにスキップ

GitHub Releases からバイナリをインストールする 6 つのツール

GitHub Releases のバイナリをダウンロードし、実行できる場所へ配置する作業を自動化する 6 つのツールを試しました。リリースの選び方や更新機能の違い、各ツールの使い方を整理します。

GitHub Releases では、OS と CPU アーキテクチャに合わせたビルド済みバイナリを配布できます。利用者がアーカイブをダウンロードして展開し、PATH の通った場所へ配置するのが一般的です。curlやtarを使えば追加のセットアップなしにこの作業を済ませられますが、コマンドを毎回実行するのはやや手間です。

この記事で扱うのは、次の 6 つのツールです。

以降のコマンド例と実行結果は、執筆時点のものです。各ツールの仕様や GitHub のリリース状況によって、現在は異なる場合があります。

installer

Installer はシェルスクリプトを返す HTTP サーバーです。返されたスクリプトは、プラットフォームの OS とアーキテクチャを検出し、URL のセレクションから選択し、適切なファイルをダウンロードし、ファイルを un(zip|tar|gzip)し、バイナリ(最大ファイル)を見つけ、オプションで PATH に移動します。お気に入りのコンパイル済みプログラムを curl だけでインストールするのに便利です。

— jpillora/installer

installer は、シェルスクリプトを返す HTTP サーバーです。返されるスクリプトがプラットフォームを自動検知して対応するバイナリをダウンロード・展開・配置するため、curl 1 つでインストールを完結できます。

使い方

curl で対象のリポジトリを指定するだけでインストールできますが、取得したスクリプトを確認せずにbashへ渡すため、実行前にスクリプトの内容と配布元を確認します。

# install <user>/<repo> from github
curl https://i.jpillora.com/<user>/<repo>@<release>! | bash
例
1
2
3
4
5
6
$ curl -s i.jpillora.com/mholt/caddy! | bash
Downloading mholt/caddy v0.8.2 (https://github.com/mholt/caddy/releases/download/v0.8.2/caddy_darwin_amd64.zip)
######################################################################## 100.0%
Downloaded to /usr/local/bin/caddy
$ caddy --version
Caddy 0.8.2

Private repository にも対応しており、必要な設定はREADME の Private repos の節で確認できます。

gh-install

gh-install は GitHub Releases からバイナリをインストールするためのスクリプトです。対象のリポジトリを指定して実行します。

使い方

1
2
3
$ ./install.sh --git <org>/<repo>
# Or
PS install.ps1 -git <org>/<repo>

dra

GitHub からリリースアセットをダウンロードするためのコマンドラインツール。

— devmatteini/dra

Rust で書かれたシングルバイナリのツールです。実行環境に対応するリリースアセットを自動でダウンロードできるほか、オプションや対話形式でダウンロードする対象を選べます。

setup

brew install dra

usage

1
2
3
4
dra download devmatteini/dra-tests

# you can use -a or --automatic
dra download -a devmatteini/dra-tests

dra

bin

複数のツールを導入するためのツールで、バイナリだけでなく Docker image も CLI ツールとして利用できるようにします。

1
2
3
4
5
6
7
8
9
bin install github.com/kubernetes-sigs/kind # installs latest Kind release

bin install github.com/kubernetes-sigs/kind/releases/tag/v0.8.0 # installs a specific release

bin install github.com/kubernetes-sigs/kind ~/bin/kind # installs latest on a specific path

bin install docker://hashicorp/terraform:light # install the `light` tag for terraform

bin install docker://quay.io/calico/node # install the latest version of calico/node

bin

list コマンドでインストール済みのツールを確認し、update コマンドでツールを更新できます。

1
2
3
4
5
6
7
8
9
bin ensure # Ensures that all binaries listed in the configuration are present
bin help # Help about any command
bin install <repo> [path] # Downloads the latest binary and makes it executable
bin list # List current binaries and it's versions
bin prune # Removes from the DB missing binaries
bin remove <bin>... # Deletes one or more binaries
bin update [bin]... # Scans binaries and prompts for update
bin pin <bin>... # Pins current version of one or more binaries
bin unpin <bin>... # Unpins one or more binaries

eget

eget も GitHub Releases からバイナリをインストールするためのツールです。curl でインストールできます。

curl https://zyedidia.github.io/eget.sh | sh
例
eget zyedidia/micro --tag nightly
eget jgm/pandoc --to /usr/local/bin
eget junegunn/fzf
eget neovim/neovim
eget ogham/exa --asset ^musl
eget --system darwin/amd64 sharkdp/fd
eget BurntSushi/ripgrep
eget -f eget.1 zyedidia/eget
eget zachjs/sv2v
eget https://go.dev/dl/go1.17.5.linux-amd64.tar.gz --file go --to ~/go1.17.5
eget --all --file '*' ActivityWatch/activitywatch

eget

対話形式で、インストールするバイナリを選択できます。--upgrade-onlyオプションを使うと、バイナリがすでに導入されている場合にだけ更新します。

install-release

install-release は、GitHub のリリースからあなたのデバイス用のツールを直接インストールし、それらを更新しておくための CLI ツールです。GitHub のリリースからツールをインストールするための小さなパッケージ・マネージャーと考えてください。

— Rishang/install-release

パッケージマネージャーに近い機能を持ち、インストール以外にlsやupgradeなど複数のコマンドを利用できます。

setup

# Install install-release
pip install -U install-release

usage

1
2
3
4
5
# Example Installation a tool named `gron` directly from its GitHub releases

# install-release get [GITHUB-URL]

❯ install-release get https://github.com/tomnomnom/gron
例
❯ install-release get "https://github.com/ahmetb/kubectx"

📑 Repo     : ahmetb/kubectx
🌟 Stars    : 13295
✨ Language : Go
🔥 Title    : Faster way to switch between clusters and namespaces in kubectl

                              🚀 Install: kubectx
┏━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━┓
┃ Name    ┃ Selected Item                      ┃ Version ┃ Size Mb ┃ Downloads ┃
┡━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━┩
│ kubectx │ kubectx_v0.9.4_linux_x86_64.tar.gz │ v0.9.4  │ 1.0     │ 43811     │
└─────────┴────────────────────────────────────┴─────────┴─────────┴───────────┘
Install this tool (Y/n): y
 INFO     Downloaded: 'kubectx_v0.9.4_linux_x86_64.tar.gz' at /tmp/dn_kubectx_ph6i7dmk                                                               utils.py:159
 INFO     install /tmp/dn_kubectx_ph6i7dmk/kubectx /home/noobi/bin/kubectx                                                                  core.py:132
 INFO     Installed: kubectx

まとめ

この記事では、GitHub Releases からバイナリをインストールする 6 つのツールを紹介しました。curl 1 つで済ませたいなら installer、Docker image も CLI ツールとして扱いたいなら bin のように、ツールごとに得意な場面が異なります。一覧表示や更新機能を比べる際は、bin も候補になります。私自身は、当時試した中ではegetとinstall-releaseを使いやすいと感じました。