Make the build work
This commit was merged in pull request #12.
This commit is contained in:
39
scripts/install_tea.sh
Executable file
39
scripts/install_tea.sh
Executable file
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail
|
||||
|
||||
if [ -x ./tea ]; then
|
||||
echo "tea already installed in current directory"; exit 0
|
||||
fi
|
||||
|
||||
platform="${1:-linux-amd64}"
|
||||
src="${2:-release.json}"
|
||||
|
||||
# obtain JSON: if src looks like a URL fetch it, otherwise treat as filename (or default file)
|
||||
if [[ "$src" =~ ^https?:// ]]; then
|
||||
curl -fsSL "$src" -o /tmp/release.json.$$
|
||||
json="/tmp/release.json.$$"
|
||||
trap 'rm -f "$json"' EXIT
|
||||
elif [ -f "$src" ]; then
|
||||
json="$src"
|
||||
else
|
||||
echo "release JSON not found; provide a filename or URL as second arg" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# read tag and find binary URL (exclude archives/checksums/sigs)
|
||||
tag=$(jq -r '.tag_name' "$json")
|
||||
url=$(jq -r --arg p "$platform" '.assets[]
|
||||
| select(.name | test($p))
|
||||
| select(.name | test("\\.(xz|zip|gz|tar|bz2|7z|sha256|sha256sum|sig|asc)$") | not)
|
||||
| .browser_download_url' "$json" | head -n1)
|
||||
|
||||
[ -n "$url" ] || { echo "binary not found for $platform" >&2; exit 1; }
|
||||
|
||||
tmp="$(mktemp)"
|
||||
trap 'rm -f "$tmp"' EXIT
|
||||
|
||||
curl -fsSL "$url" -o "$tmp"
|
||||
mv "$tmp" tea
|
||||
chmod +x tea
|
||||
echo "Downloaded tag ${tag}: $url -> ./tea"
|
||||
|
||||
Reference in New Issue
Block a user