2021-10-10 15:49:50 +00:00
|
|
|
#!/usr/bin/env nix-shell
|
|
|
|
#!nix-shell -i bash -p curl gnused nix-prefetch jq
|
|
|
|
|
|
|
|
set -eou pipefail
|
|
|
|
|
|
|
|
dirname="$(dirname "$0")"
|
|
|
|
|
|
|
|
updateHash()
|
|
|
|
{
|
2023-02-20 12:01:06 +00:00
|
|
|
# nixos
|
2021-10-10 15:49:50 +00:00
|
|
|
version=$1
|
2023-02-20 12:01:06 +00:00
|
|
|
system=$2
|
2021-10-10 15:49:50 +00:00
|
|
|
|
2023-02-20 12:01:06 +00:00
|
|
|
# prowlarr
|
|
|
|
arch=$3
|
|
|
|
os=$4
|
2021-10-10 15:49:50 +00:00
|
|
|
|
2023-02-20 12:01:06 +00:00
|
|
|
url="https://github.com/Prowlarr/Prowlarr/releases/download/v$version/Prowlarr.master.$version.$os-core-$arch.tar.gz"
|
2021-10-10 15:49:50 +00:00
|
|
|
hash=$(nix-prefetch-url --type sha256 $url)
|
|
|
|
sriHash="$(nix hash to-sri --type sha256 $hash)"
|
|
|
|
|
2023-02-20 12:01:06 +00:00
|
|
|
sed -i "s|$system = \"sha256-[a-zA-Z0-9\/+-=]*\";|$system = \"$sriHash\";|g" "$dirname/default.nix"
|
2021-10-10 15:49:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
updateVersion()
|
|
|
|
{
|
|
|
|
sed -i "s/version = \"[0-9.]*\";/version = \"$1\";/g" "$dirname/default.nix"
|
|
|
|
}
|
|
|
|
|
|
|
|
currentVersion=$(cd $dirname && nix eval --raw -f ../../.. prowlarr.version)
|
|
|
|
|
2023-02-20 12:01:06 +00:00
|
|
|
latestTag=$(curl https://api.github.com/repos/Prowlarr/Prowlarr/releases/latest | jq -r ".tag_name")
|
|
|
|
latestVersion="$(expr $latestTag : 'v\(.*\)')"
|
2021-10-10 15:49:50 +00:00
|
|
|
|
|
|
|
if [[ "$currentVersion" == "$latestVersion" ]]; then
|
|
|
|
echo "Prowlarr is up-to-date: ${currentVersion}"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
updateVersion $latestVersion
|
|
|
|
|
2023-02-20 12:01:06 +00:00
|
|
|
updateHash $latestVersion aarch64-darwin arm64 osx
|
|
|
|
updateHash $latestVersion aarch64-linux arm64 linux
|
|
|
|
updateHash $latestVersion x86_64-darwin x64 osx
|
|
|
|
updateHash $latestVersion x86_64-linux x64 linux
|