codeium: 1.24.2 -> 1.30.2 (#363819)
[NixPkgs.git] / pkgs / servers / search / typesense / update.sh
blob3dec74232f46bd5231d6cb4d7328084c7217f9c0
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
4 set -euo pipefail
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")
9 version="${version#v}"
11 if [[ "$old_version" == "$version" ]]; then
12 echo "Already up to date!"
13 exit 0
16 declare -A platforms=(
17 [aarch64-linux]="linux-arm64"
18 [aarch64-darwin]="darwin-arm64"
19 [x86_64-darwin]="darwin-amd64"
20 [x86_64-linux]="linux-amd64"
23 sources_tmp="$(mktemp)"
24 cat <<EOF > "$sources_tmp"
26 "version": "$version",
27 "platforms": {}
29 EOF
31 for platform in "${!platforms[@]}"; do
32 arch="${platforms[$platform]}"
33 url="https://dl.typesense.org/releases/${version}/typesense-server-${version}-${arch}.tar.gz"
34 sha256hash="$(nix-prefetch-url --type sha256 "$url")"
35 hash="$(nix hash to-sri --type sha256 "$sha256hash")"
36 echo "$(jq --arg arch "$arch" \
37 --arg platform "$platform" \
38 --arg hash "$hash" \
39 '.platforms += {($platform): {arch: $arch, hash: $hash}}' \
40 "$sources_tmp")" > "$sources_tmp"
41 done
43 cp "$sources_tmp" sources.json