biglybt: 3.5.0.0 -> 3.6.0.0
[NixPkgs.git] / pkgs / servers / search / typesense / update.sh
blobc6d733181cd399b5882a82de6ac3c39021e5804b
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 [x86_64-darwin]="darwin-amd64"
19 [x86_64-linux]="linux-amd64"
22 sources_tmp="$(mktemp)"
23 cat <<EOF > "$sources_tmp"
25 "version": "$version",
26 "platforms": {}
28 EOF
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" \
37 --arg hash "$hash" \
38 '.platforms += {($platform): {arch: $arch, hash: $hash}}' \
39 "$sources_tmp")" > "$sources_tmp"
40 done
42 cp "$sources_tmp" sources.json