1 #!/usr/bin/env nix-shell
2 #!nix-shell -i bash -p curl jq nix-prefetch common-updater-scripts nix coreutils
3 # shellcheck shell=bash
5 cd "$(dirname "${BASH_SOURCE[0]}")"
7 old_version
=$
(jq
-r ".version" sources.json ||
echo -n "0.0.1")
8 version
=$
(curl
-s "https://api.github.com/repos/typesense/typesense/releases/latest" | jq
-r ".tag_name")
11 if [[ "$old_version" == "$version" ]]; then
12 echo "Already up to date!"
16 declare -A platforms
=(
17 [aarch64-linux
]="linux-arm64"
18 [x86_64-darwin
]="darwin-amd64"
19 [x86_64-linux
]="linux-amd64"
22 sources_tmp
="$(mktemp)"
23 cat <<EOF > "$sources_tmp"
25 "version": "$version",
30 for platform
in "${!platforms[@]}"; do
31 arch
="${platforms[$platform]}"
32 url
="https://dl.typesense.org/releases/${version}/typesense-server-${version}-${arch}.tar.gz"
33 sha256hash
="$(nix-prefetch-url --type sha256 "$url")"
34 hash="$(nix hash to-sri --type sha256 "$sha256hash")"
35 echo "$(jq --arg arch "$arch" \
36 --arg platform "$platform" \
38 '.platforms += {($platform): {arch: $arch, hash: $hash}}' \
39 "$sources_tmp")" > "$sources_tmp"
42 cp "$sources_tmp" sources.json