This solution downloads the latest release tar.gz
archive of a GitHub repository with GitHub CLI command line.
To use the gh release download command we need to pick the tag of the latest release, here is how
gh release list --limit 1 --json "tagName" --jq ".[].tagName"
Then provide this tag to the gh release download
command
gh release download \
"$(gh release list --limit 1 --json "tagName" --jq ".[].tagName")" \
--archive="tar.gz"
The overall code π
#!/usr/bin/env bash
# -*- coding: UTF-8 -*-
#
# github : https://github.com/JV-conseil
# www : https://www.jv-conseil.net
# author : JV-conseil
#
# gh release download & list
# see: <https://cli.github.com/manual/gh_release_download>
#
#====================================================
# Retrieve the tag of the latest release
_jvcl_::gh_release_latest_tag() {
gh release list --limit 1 --json "tagName" --jq ".[].tagName"
}
# Download the latest release archive in tar.gz
# to a local directory
_jvcl_::gh_release_download() {
local _dir_backup="${1:-"./Downloads"}"
gh release download \
"$(_jvcl_::gh_release_latest_tag)" \
--archive="tar.gz" \
--dir="${_dir_backup}"
}
_jvcl_::gh_release_download "./path_to_a_folder"
This solution does not provide a link stricto sensu as requested by the question, but is convenient to work with public and private repositories.
π Read the answer on stackoverflow.com