download-release-action
download-release-action copied to clipboard
Select release asset by mask
If we are downloading by latest
tag, we cannot know full file name before had download assets release information.
Is useful case when some assets contains version number.
We can implement it using the Regular expressions of jq. Then the first asset machting the given expression will by downloaded for the given tag.
I just stumbled upon this while trying to download the latest Linux x64 qsv binary. I came up with the same script:
set -e
set -o pipefail
releases_url='https://api.github.com/repos/jqnatividad/qsv/releases/latest'
assets_url="$(
curl "$releases_url" -H 'Accept: application/json' -L -s \
| jq -r '.assets_url'
)"
qsv_x64_url="$(
curl "$assets_url" -H 'Accept: application/json' -L -s \
| jq -r '.[] | select(.name | test("qsv-[0-9.]+-x86_64-unknown-linux-gnu.zip")) | .browser_download_url'
)"