1+ #! /bin/bash
2+ set -euo pipefail
3+
4+ # Configuration
5+ REPO=" wavezync/pulse-bridge"
6+ BINARY_NAME=" pulse-bridge"
7+ INSTALL_DIR=" ${INSTALL_DIR:-/ usr/ local/ bin} "
8+
9+ get_arch () {
10+ case $( uname -m) in
11+ x86_64) echo " amd64" ;;
12+ arm64|aarch64) echo " arm64" ;;
13+ i386|i686) echo " 386" ;;
14+ armv7l) echo " arm" ;;
15+ * ) echo " Unsupported architecture: $( uname -m) " >&2 ; exit 1 ;;
16+ esac
17+ }
18+
19+ get_os () {
20+ case $( uname -s | tr ' [:upper:]' ' [:lower:]' ) in
21+ linux) echo " linux" ;;
22+ darwin) echo " darwin" ;;
23+ freebsd) echo " freebsd" ;;
24+ openbsd) echo " openbsd" ;;
25+ netbsd) echo " netbsd" ;;
26+ dragonfly) echo " dragonfly" ;;
27+ solaris) echo " solaris" ;;
28+ mingw* |msys* |cygwin* ) echo " windows" ;;
29+ * ) echo " Unsupported OS: $( uname -s) " >&2 ; exit 1 ;;
30+ esac
31+ }
32+
33+ main () {
34+ local os arch binary_name download_url temp_dir
35+
36+ os=$( get_os)
37+ arch=$( get_arch)
38+ binary_name=" $BINARY_NAME "
39+
40+ echo " 🔍 Getting latest release info..."
41+
42+ # Get latest release
43+ local latest_release
44+ latest_release=$( curl -s " https://api.github.com/repos/$REPO /releases/latest" | \
45+ grep ' "tag_name":' | \
46+ sed -E ' s/.*"([^"]+)".*/\1/' )
47+
48+ if [[ -z " $latest_release " ]]; then
49+ echo " ❌ Could not find latest release" >&2
50+ exit 1
51+ fi
52+
53+ # Construct filename based on your naming convention: pulse-bridge-{version}-{os}-{arch}
54+ local filename=" ${BINARY_NAME} -${latest_release} -${os} -${arch} "
55+
56+ if [[ " $os " == " windows" ]]; then
57+ filename=" ${filename} .exe"
58+ binary_name=" ${binary_name} .exe"
59+ fi
60+
61+ download_url=" https://github.com/$REPO /releases/download/$latest_release /$filename "
62+
63+ echo " 📦 Installing $BINARY_NAME $latest_release for $os /$arch ..."
64+ echo " 🔗 Downloading: $filename "
65+
66+ # Create temporary directory
67+ temp_dir=$( mktemp -d)
68+ trap " rm -rf $temp_dir " EXIT
69+
70+ # Download
71+ if ! curl -L --fail --progress-bar " $download_url " -o " $temp_dir /$binary_name " ; then
72+ echo " ❌ Failed to download binary from: $download_url "
73+ echo " 📋 Available platforms:"
74+ echo " Linux: amd64, arm64, 386, mips64, mips64le, ppc64, ppc64le"
75+ echo " macOS: amd64, arm64"
76+ echo " Windows: amd64, arm64, 386"
77+ echo " BSD: FreeBSD, OpenBSD, NetBSD, DragonFly"
78+ echo " Solaris: amd64"
79+ exit 1
80+ fi
81+
82+ chmod +x " $temp_dir /$binary_name "
83+
84+ # Install
85+ echo " 📍 Installing to $INSTALL_DIR ..."
86+ if [[ ! -d " $INSTALL_DIR " ]]; then
87+ mkdir -p " $INSTALL_DIR "
88+ fi
89+
90+ if [[ -w " $INSTALL_DIR " ]]; then
91+ mv " $temp_dir /$binary_name " " $INSTALL_DIR /"
92+ else
93+ echo " 🔐 Requesting sudo access to install to $INSTALL_DIR ..."
94+ sudo mv " $temp_dir /$binary_name " " $INSTALL_DIR /"
95+ fi
96+
97+ echo " "
98+ echo " 🎉 $BINARY_NAME installed successfully!"
99+ echo " 📍 Location: $INSTALL_DIR /$BINARY_NAME "
100+ echo " 🚀 Run '$BINARY_NAME --help' to get started"
101+ echo " "
102+ echo " 📖 Documentation: https://github.com/$REPO "
103+ }
104+
105+ main " $@ "
0 commit comments