feat: add install script for nkeys

Installs the nk CLI from nats-io/nkeys releases. The release zip
nests everything under a nkeys-v<version>-<os>-<arch>/ directory
(binary is named nk, not nkeys), so set_link points at that nested
path rather than flattening the archive.
main
Buddy 2 days ago
parent f97e827c09
commit 4e2961062b

@ -0,0 +1,38 @@
#!/usr/bin/env bash
set -euo pipefail
# shellcheck disable=SC1091
source "${XDG_DATA_HOME}/buddy-up/includes/utils.sh"
APP=nkeys
VERSION=${VERSION:-0.4.16}
DEST=${XDG_DATA_HOME}/apps/releases/${APP}
main() (
ARCHIVE_DIR=nkeys-v${VERSION}-$(get_os)-$(get_arch)
URL=https://github.com/nats-io/nkeys/releases/download/v${VERSION}/${ARCHIVE_DIR}.zip
extract_zip "${URL}" "${DEST}/${VERSION}"
set_current_link "${DEST}" "${VERSION}"
set_link "${XDG_BIN_HOME}/nk" "${DEST}" "${ARCHIVE_DIR}/nk"
)
get_arch () (
case $(uname -m) in
x86_64*) echo amd64 ;;
arm64*) echo arm64 ;;
aarch64*) echo arm64 ;;
*) >&2 echo "unsupported uname: $(uname -m)"; exit 1 ;;
esac
)
get_os () (
case $(uname -s) in
Linux*) echo linux ;;
Darwin*) echo darwin ;;
*) >&2 echo "unsupported os: $(uname -s)"; exit 1 ;;
esac
)
main "${@}"
Loading…
Cancel
Save