heroic: use qt6 version of kdialog (#372495)
[NixPkgs.git] / pkgs / by-name / ti / tigerbeetle / update.sh
blob903d875df681bf47bada5957489dbc6c9040b79c
1 #!/usr/bin/env nix-shell
2 #!nix-shell -i bash -p curl jq nix mktemp unzip gnused
4 set -euo pipefail
6 latest_release_info=$(curl -s ${GITHUB_TOKEN:+ -H "Authorization: Bearer $GITHUB_TOKEN"} https://api.github.com/repos/tigerbeetle/tigerbeetle/releases?per_page=5 | jq -r "map(select(.properties.draft and .properties.prerelease | not)) | .[0]")
7 latestVersion=$(jq -r ".tag_name" <<< $latest_release_info)
8 currentVersion=$(nix-instantiate --eval -E "let pkgs = import ./. {}; in pkgs.tigerbeetle.version" | tr -d '"')
10 if [[ "$currentVersion" == "$latestVersion" ]]
11 then
12 echo "New version same as old version, nothing to do." >&2
13 exit 0
16 # Note: our own nix-prefetch-url impersonation because the way that nix-prefetch-url treats tigerbeetle's zip files (which are just a single executable, no directories) is different from how Nixpkgs's fetchzip treats them.
17 retrieved_hash=""
18 function retrieve_hash {
19 download_dir=$(mktemp -d)
20 curl -s --location $1 --output "$download_dir/tigerbeetle.zip"
21 unzip -q "$download_dir/tigerbeetle.zip" -d "$download_dir"
22 rm "$download_dir/tigerbeetle.zip"
23 retrieved_hash=$(nix --extra-experimental-features nix-command hash path "$download_dir")
24 rm -rf "$download_dir"
27 nixFile=$(nix-instantiate --eval --strict -A "tigerbeetle.meta.position" | sed -re 's/^"(.*):[0-9]+"$/\1/')
29 sed -i "s|\(version = \"\)\(.*\)\"|\1$latestVersion\"|" $nixFile
30 retrieve_hash "https://github.com/tigerbeetle/tigerbeetle/releases/download/${latestVersion}/tigerbeetle-x86_64-linux.zip"
31 sed -i "s|\(\"x86_64-linux\" = \"\)\(.*\)\"|\1$retrieved_hash\"|" $nixFile
32 retrieve_hash "https://github.com/tigerbeetle/tigerbeetle/releases/download/${latestVersion}/tigerbeetle-aarch64-linux.zip"
33 sed -i "s|\(\"aarch64-linux\" = \"\)\(.*\)\"|\1$retrieved_hash\"|" $nixFile
34 retrieve_hash "https://github.com/tigerbeetle/tigerbeetle/releases/download/${latestVersion}/tigerbeetle-universal-macos.zip"
35 sed -i "s|\(\"universal-macos\" = \"\)\(.*\)\"|\1$retrieved_hash\"|" $nixFile