biglybt: 3.5.0.0 -> 3.6.0.0
[NixPkgs.git] / pkgs / servers / ombi / update.sh
blob9b49180b6f116ac0799fd37b07fbc6d08a782f06
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/Ombi-app/Ombi/releases/download/v$version/$os-$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 ../../.. ombi.version)
30 latestTag=$(curl https://api.github.com/repos/Ombi-App/Ombi/releases/latest | jq -r ".tag_name")
31 latestVersion="$(expr $latestTag : 'v\(.*\)')"
33 if [[ "$currentVersion" == "$latestVersion" ]]; then
34 echo "Ombi is up-to-date: ${currentVersion}"
35 exit 0
38 updateVersion $latestVersion
40 updateHash $latestVersion x64 linux
41 updateHash $latestVersion arm64 linux
42 updateHash $latestVersion x64 osx