LoginSignup
0
0

シェルスクリプトでGithub Release から最新版をダウンロードする

Posted at

はじめに

同じものはたくさんあるけれど、自分で手軽に利用したかったので作ってみた。
実際は curl と jq を呼んでいるだけ。
ファイル名の先頭一致で抽出しているので、似たファイル名が存在していると目的のファイルを取得できない可能性がある。

例はいつものお世話になっている yuru7 さんのフォントをダウンロード

コード

#!/bin/bash

function download_gh_release() {
  echo Download $2 from github: $1
  curl -sLO $(curl -s https://api.github.com/repos/$1/releases/latest | jq -r '.assets[] | select(.name | startswith("'"$2"'")) | .browser_download_url')
}

download_gh_release yuru7/moralerspace MoralerspaceNF
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0