biglybt: 3.5.0.0 -> 3.6.0.0
[NixPkgs.git] / pkgs / servers / readarr / update.sh
blob0372ac9fa1a4e4dfbce64bbaeecaa5707b18af16
1 #!/usr/bin/env nix-shell
2 #!nix-shell -i bash -p curl gnused nix-prefetch jq
4 set -e
6 dirname="$(dirname "$0")"
8 updateHash()
10 version=$1
11 arch=$2
12 os=$3
14 hashKey="${arch}-${os}_hash"
16 url="https://github.com/Readarr/Readarr/releases/download/v$version/Readarr.develop.$version.$os-core-$arch.tar.gz"
17 hash=$(nix-prefetch-url --type sha256 $url)
18 sriHash="$(nix hash to-sri --type sha256 $hash)"
20 sed -i "s|$hashKey = \"[a-zA-Z0-9\/+-=]*\";|$hashKey = \"$sriHash\";|g" "$dirname/default.nix"
23 updateVersion()
25 sed -i "s/version = \"[0-9.]*\";/version = \"$1\";/g" "$dirname/default.nix"
28 currentVersion=$(cd $dirname && nix eval --raw -f ../../.. readarr.version)
30 # We cannot use the latest releases as in the past Readarr released old version with v2.0 and then went back to 0.1
31 latestTag=$(curl https://api.github.com/repos/Readarr/Readarr/releases | jq -r ".[0].tag_name")
32 latestVersion="$(expr $latestTag : 'v\(.*\)')"
34 if [[ "$currentVersion" == "$latestVersion" ]]; then
35 echo "Readarr is up-to-date: ${currentVersion}"
36 exit 0
39 updateVersion $latestVersion
41 updateHash $latestVersion x64 linux
42 updateHash $latestVersion arm64 linux
43 updateHash $latestVersion x64 osx