mirror of
https://github.com/hanzoai/index.git
synced 2026-10-30 18:34:27 +00:00
Devs are the users here, so an internal name is a user-visible name. This finishes what the previous commit started on the serving surface: MEILISEARCH_* / meilisearch_* -> INDEX_* / index_* (statics, metrics) MEILI_* -> INDEX_* (env vars) Meili-Include-Metadata -> Index-Include-Metadata (HTTP header) MeiliParams, meili_client, setup_meilisearch, and every remaining prose mention -> the index equivalents 519 files, 1621 insertions and 1621 deletions — a 1:1 substitution, no structural change. **This changes the deployment contract**: the binary now reads INDEX_MASTER_KEY, INDEX_ENV and INDEX_DB_PATH. The App CR in hanzoai/universe must move to those names IN THE SAME ROLLOUT as the new image — the running 1.37.0 still reads MEILI_*, so flipping the CR early would start it with no master key. CI now publishes ghcr.io/hanzoai/index, matching the repo. There is no Rust toolchain on the box this was authored on, and building images locally is against policy anyway, so CI is the compiler: a red build here costs nothing because production is pinned to 1.37.0 and is not touched by it. NOT renamed: the crate/directory names (milli, search, search-types...). Those move Cargo.toml paths and workspace members together and deserve their own verified pass, not a blind one. Co-authored-by: Hanzo Dev <[email protected]>
170 lines
4.3 KiB
Bash
170 lines
4.3 KiB
Bash
#!/bin/sh
|
|
|
|
# This script can optionally use a GitHub token to increase your request limit (for example, if using this script in a CI).
|
|
# To use a GitHub token, pass it through the GITHUB_PAT environment variable.
|
|
|
|
# GLOBALS
|
|
|
|
# Colors
|
|
RED='\033[31m'
|
|
GREEN='\033[32m'
|
|
DEFAULT='\033[0m'
|
|
|
|
# Project name
|
|
PNAME='index'
|
|
|
|
# GitHub API address
|
|
GITHUB_API='https://api.github.com/repos/hanzoai/index/releases'
|
|
# GitHub Release address
|
|
GITHUB_REL='https://github.com/hanzoai/index/releases/download/'
|
|
|
|
# FUNCTIONS
|
|
|
|
# Gets the version of the latest stable version of Hanzo Index by setting the $latest variable.
|
|
# Returns 0 in case of success, 1 otherwise.
|
|
get_latest() {
|
|
# temp_file is needed because the grep would start before the download is over
|
|
temp_file=$(mktemp -q /tmp/$PNAME.XXXXXXXXX)
|
|
latest_release="$GITHUB_API/latest"
|
|
|
|
if [ $? -ne 0 ]; then
|
|
echo "$0: Can't create temp file."
|
|
fetch_release_failure_usage
|
|
exit 1
|
|
fi
|
|
|
|
if [ -n "$GITHUB_TOKEN" ]; then
|
|
curl -H "Authorization: Bearer $GITHUB_TOKEN" -s "$latest_release" > "$temp_file" || return 1
|
|
elif [ -n "$GITHUB_PAT" ]; then
|
|
curl -H "Authorization: token $GITHUB_PAT" -s "$latest_release" > "$temp_file" || return 1
|
|
else
|
|
curl -s "$latest_release" > "$temp_file" || return 1
|
|
fi
|
|
|
|
latest="$(cat "$temp_file" | grep '"tag_name":' | cut -d ':' -f2 | tr -d '"' | tr -d ',' | tr -d ' ')"
|
|
|
|
rm -f "$temp_file"
|
|
return 0
|
|
}
|
|
|
|
# Gets the OS by setting the $os variable.
|
|
# Returns 0 in case of success, 1 otherwise.
|
|
get_os() {
|
|
os_name=$(uname -s)
|
|
case "$os_name" in
|
|
'Darwin')
|
|
os='macos'
|
|
;;
|
|
'Linux')
|
|
os='linux'
|
|
;;
|
|
'MINGW'*)
|
|
os='windows'
|
|
;;
|
|
*)
|
|
return 1
|
|
esac
|
|
return 0
|
|
}
|
|
|
|
# Gets the architecture by setting the $archi variable.
|
|
# Returns 0 in case of success, 1 otherwise.
|
|
get_archi() {
|
|
architecture=$(uname -m)
|
|
case "$architecture" in
|
|
'x86_64' | 'amd64' )
|
|
archi='amd64'
|
|
;;
|
|
'arm64')
|
|
# macOS M1/M2
|
|
if [ $os = 'macos' ]; then
|
|
archi='apple-silicon'
|
|
else
|
|
archi='aarch64'
|
|
fi
|
|
;;
|
|
'aarch64')
|
|
archi='aarch64'
|
|
;;
|
|
*)
|
|
return 1
|
|
esac
|
|
return 0
|
|
}
|
|
|
|
success_usage() {
|
|
printf "$GREEN%s\n$DEFAULT" "Hanzo Index $latest binary successfully downloaded as '$binary_name' file."
|
|
echo ''
|
|
echo 'Run it:'
|
|
echo " $ ./$PNAME"
|
|
echo 'Usage:'
|
|
echo " $ ./$PNAME --help"
|
|
}
|
|
|
|
not_available_failure_usage() {
|
|
printf "$RED%s\n$DEFAULT" 'ERROR: Hanzo Index binary is not available for your OS distribution or your architecture yet.'
|
|
echo ''
|
|
echo 'However, you can easily compile the binary from the source files.'
|
|
echo 'Follow the steps at the page ("Source" tab): https://www.hanzo.ai/docs/learn/getting_started/installation'
|
|
}
|
|
|
|
fetch_release_failure_usage() {
|
|
echo ''
|
|
printf "$RED%s\n$DEFAULT" 'ERROR: Impossible to get the latest stable version of Hanzo Index.'
|
|
echo 'Please let us know about this issue: https://github.com/hanzoai/index/issues/new/choose'
|
|
echo ''
|
|
echo 'In the meantime, you can manually download the appropriate binary from the GitHub release assets here: https://github.com/hanzoai/index/releases/latest'
|
|
}
|
|
|
|
fill_release_variables() {
|
|
# Fill $latest variable.
|
|
if ! get_latest; then
|
|
fetch_release_failure_usage
|
|
exit 1
|
|
fi
|
|
if [ "$latest" = '' ]; then
|
|
fetch_release_failure_usage
|
|
exit 1
|
|
fi
|
|
# Fill $os variable.
|
|
if ! get_os; then
|
|
not_available_failure_usage
|
|
exit 1
|
|
fi
|
|
# Fill $archi variable.
|
|
if ! get_archi; then
|
|
not_available_failure_usage
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
download_binary() {
|
|
fill_release_variables
|
|
echo "Downloading Hanzo Index binary $latest for $os, architecture $archi..."
|
|
case "$os" in
|
|
'windows')
|
|
release_file="$PNAME-$os-$archi.exe"
|
|
binary_name="$PNAME.exe"
|
|
;;
|
|
*)
|
|
release_file="$PNAME-$os-$archi"
|
|
binary_name="$PNAME"
|
|
esac
|
|
# Fetch the Hanzo Index binary.
|
|
curl --fail -OL "$GITHUB_REL/$latest/$release_file"
|
|
if [ $? -ne 0 ]; then
|
|
fetch_release_failure_usage
|
|
exit 1
|
|
fi
|
|
mv "$release_file" "$binary_name"
|
|
chmod 744 "$binary_name"
|
|
success_usage
|
|
}
|
|
|
|
# MAIN
|
|
|
|
main() {
|
|
download_binary
|
|
}
|
|
main
|