setbfree: 0.8.12 -> 0.8.13 (#372025)
[NixPkgs.git] / pkgs / by-name / wh / whisparr / update.sh
blob6e9b69e65a02ae24d500c7aea2b3ce508c67468e
1 #!/usr/bin/env nix-shell
2 #!nix-shell -i bash -p curl gnused jq nix-prefetch
3 #shellcheck shell=bash
5 set -e
7 dirname="$(dirname "$0")"
9 updateVersion() {
10 version=$1
11 echo "Updating the version..."
12 sed -i "s#version = \"[0-9.]*\"#version = \"$version\"#" "$dirname/package.nix"
15 updateHash()
17 version=$1
18 arch=$2
19 os=$3
21 system="${arch}-${os}"
22 hashKey="${system}-hash"
24 echo "Updating the hash for the \`${system}\` system..."
25 url="https://whisparr.servarr.com/v1/update/nightly/updatefile?runtime=netcore&version=${version}&arch=${arch}&os=${os}"
26 hash=$(nix-prefetch-url --type sha256 --name "whisparr-$system-$version.tar.gz" "$url")
27 sriHash="$(nix hash to-sri --type sha256 "$hash")"
29 sed -i "s#$hashKey = \"[a-zA-Z0-9\/+-=]*\"#$hashKey = \"$sriHash\"#" "$dirname/package.nix"
32 echo "Checking for updates of Whisparr..."
34 currentVersion=$(nix eval --raw -f "$dirname"/../../../.. whisparr.version)
35 echo "Current version: \`$currentVersion\`."
37 echo "Fetching the latest version..."
38 latestVersion=$(
39 curl -s "https://whisparr.servarr.com/v1/update/nightly/changes?runtime=netcore&os=linux" |
40 jq -r .[0].version
43 if [[ "$currentVersion" == "$latestVersion" ]]; then
44 echo "Whisparr is up-to-date."
45 exit 0
46 else
47 echo "New version is available: \`$latestVersion\`."
50 updateHash "$latestVersion" arm64 linux
51 updateHash "$latestVersion" arm64 osx
52 updateHash "$latestVersion" x64 linux
53 updateHash "$latestVersion" x64 osx
55 updateVersion "$latestVersion"