dotfiles/_src.posix/private_dot_local/bin/executable_get-github-release.sh
Lockszmith (@VAST) 44b03e8724 prepare for symclone.
From now on, _src.posix will be the single source of truth.
And _home(.*) will symlink into it.
2025-02-20 23:34:24 -05:00

20 lines
549 B
Bash

#! /usr/bin/env bash
GH_PROJECT="${1}"
GH_DL_TAG="${2:-latest}"
GH_FILTER="${3:-deb}"
if [[ ! "$GH_FILTER" =~ '(' ]]; then
GH_FILTER="contains(\"${GH_FILTER}\")"
fi
SRC_URL=https://api.github.com/repos/${GH_PROJECT}/releases/${GH_DL_TAG}
DL_URL=$( \
curl -sL curl ${SRC_URL} \
| jq -r " \
.assets[] \
| select(.browser_download_url \
| ${GH_FILTER} ) \
| .browser_download_url \
")
[[ -n "$DL_URL" ]] \
&& printf "%s\n" $DL_URL \
|| return 1 2>/dev/null || exit 1