-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
65 lines (56 loc) · 2.25 KB
/
Copy pathinstall.sh
File metadata and controls
65 lines (56 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env sh
# skillpack one-command installer.
#
# Downloads the prebuilt binary for the current platform from the GitHub
# Release for a given version and installs it to ~/.local/bin (or
# $SKILLPACK_INSTALL_DIR). No Rust toolchain required.
#
# Usage:
# curl -fsSL https://raw.githubusercontent.com/nordicnode/skillpack/main/install.sh | sh
# # or pin a version:
# VERSION=0.13.0 curl -fsSL .../install.sh | sh
#
# Env vars:
# VERSION release tag to install (defaults to the latest release)
# SKILLPACK_INSTALL_DIR destination directory (default: ~/.local/bin)
set -eu
repo="nordicnode/skillpack"
bin="skillpack"
version="${VERSION:-}"
# --- resolve the version -----------------------------------------------------
if [ -z "$version" ]; then
version="$(curl -fsSL "https://api.github.com/repos/${repo}/releases/latest" \
| grep '"tag_name"' | head -n1 | sed -E 's/.*"tag_name": *"([^"]+)".*/\1/')"
fi
case "$version" in
v*) : ;;
*) version="v${version}" ;;
esac
# --- resolve the platform triple -------------------------------------------
os="$(uname -s)"
arch="$(uname -m)"
case "${os}-${arch}" in
Linux-x86_64) target="x86_64-unknown-linux-musl" ;;
# The Release workflow builds Linux arm64 with glibc (`cross` docker), not
# musl — only x86_64 has a static musl binary. Point at the gnu build that
# actually exists in the release assets.
Linux-aarch64|Linux-arm64) target="aarch64-unknown-linux-gnu" ;;
Darwin-x86_64) target="x86_64-apple-darwin" ;;
Darwin-arm64) target="aarch64-apple-darwin" ;;
*) echo "error: unsupported platform ${os}-${arch} (try cargo install skillpack)" >&2; exit 1 ;;
esac
install_dir="${SKILLPACK_INSTALL_DIR:-$HOME/.local/bin}"
mkdir -p "$install_dir"
url="https://github.com/${repo}/releases/download/${version}/${bin}-${target}.tar.gz"
tmp="$(mktemp -d)"
trap 'rm -rf "$tmp"' EXIT
echo "installing skillpack ${version} (${target}) to ${install_dir}"
curl -fsSL "$url" | tar -xz -C "$tmp"
install -m 0755 "$tmp/${bin}" "$install_dir/${bin}"
# Confirm it runs; surface a PATH hint when the dir isn't already on PATH.
"$install_dir/${bin}" --version
case ":$PATH:" in
*":${install_dir}:"*) ;;
*) echo "note: add ${install_dir} to your PATH" >&2 ;;
esac
echo "done: ${install_dir}/${bin}"