feat(bin): x-gh-get-latest-* release and version helpers

This commit is contained in:
2024-04-21 14:56:41 +03:00
parent 185d28e587
commit a90743a09c
2 changed files with 35 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
#!/usr/bin/env bash
REPO=$1
if [ -z "$REPO" ]; then
echo "Usage: $0 <repo> (e.g. ivuorinen/dotfiles)"
exit 1
fi
LOCATION=$(curl -s "https://api.github.com/repos/${REPO}/releases/latest" \
| sed -Ene '/^[[:blank:]]+"tarball_url":[[:blank:]]"(https:[^"]+)",/s//\1/p')
echo "Downloading and extracting from: $LOCATION"
curl --location --silent "$LOCATION" | tar --extract --gzip --file=-
# vim: set ts=2 sw=2 ft=sh et:

View File

@@ -0,0 +1,18 @@
#!/usr/bin/env bash
REPO=$1
if [ -z "$REPO" ]; then
echo "Usage: $0 <repo> (e.g. ivuorinen/dotfiles)"
exit 1
fi
VERSION=$(
curl -s "https://api.github.com/repos/${REPO}/releases/latest" \
| grep "tag_name" \
| awk '{print substr($2, 2, length($2)-3)}'
)
echo "$VERSION"
# vim: set ts=2 sw=2 ft=sh et: