1+ #! /bin/bash
2+
3+ # This script will download the latest libchdb release from GitHub and extract
4+ # the libchdb.so file to the current directory. This script is intended to be
5+ # used by the build process to ensure that the latest version of libchdb is
6+ # used.
7+
8+ # Change directory to the script's directory
9+ cd " $( dirname" $0 " ) "
10+
11+ # Get the newest release version
12+ LATEST_RELEASE=$( curl --silent" https://api.github.com/repos/chdb-io/chdb/releases/latest" | grep' "tag_name":' | sed -E' s/.*"([^"]+)".*/\1/' )
13+ # LATEST_RELEASE=v2.0.0b0
14+
15+ # Download the correct version based on the platform
16+ case " $( uname -s) " in
17+ Linux)
18+ if [[$( uname -m) == " aarch64" ]]; then
19+ PLATFORM=" linux-aarch64-libchdb.tar.gz"
20+ else
21+ PLATFORM=" linux-x86_64-libchdb.tar.gz"
22+ fi
23+ ;;
24+ Darwin)
25+ if [[$( uname -m) == " arm64" ]]; then
26+ PLATFORM=" macos-arm64-libchdb.tar.gz"
27+ else
28+ PLATFORM=" macos-x86_64-libchdb.tar.gz"
29+ fi
30+ ;;
31+ * )
32+ echo " Unsupported platform"
33+ exit 1
34+ ;;
35+ esac
36+
37+ DOWNLOAD_URL=" https://github.com/chdb-io/chdb/releases/download/$LATEST_RELEASE /$PLATFORM "
38+
39+ echo " Downloading$PLATFORM from$DOWNLOAD_URL "
40+
41+ # Download the file
42+ curl -L -o libchdb.tar.gz$DOWNLOAD_URL
43+
44+ # Untar the file
45+ tar -xzf libchdb.tar.gz
46+
47+ # Set execute permission for libchdb.so
48+ chmod +x libchdb.so
49+
50+ # Clean up
51+ rm -f libchdb.tar.gz