diff options
author | Alyssa Ross <hi@alyssa.is> | 2021-10-19 14:40:23 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2022-01-07 10:22:32 +0000 |
commit | cc62bcb55359ba8c5e0fe3a48e778444c89060d8 (patch) | |
tree | ca0e21d44eaf8837b687395e614445f7761d7bbd /nixpkgs/pkgs/servers/prowlarr/update.sh | |
parent | d6625e8d25efd829c3cfa227d025ca4e606ae4b7 (diff) | |
parent | a323570a264da96a0b0bcc1c9aa017794acdc752 (diff) | |
download | nixlib-cc62bcb55359ba8c5e0fe3a48e778444c89060d8.tar nixlib-cc62bcb55359ba8c5e0fe3a48e778444c89060d8.tar.gz nixlib-cc62bcb55359ba8c5e0fe3a48e778444c89060d8.tar.bz2 nixlib-cc62bcb55359ba8c5e0fe3a48e778444c89060d8.tar.lz nixlib-cc62bcb55359ba8c5e0fe3a48e778444c89060d8.tar.xz nixlib-cc62bcb55359ba8c5e0fe3a48e778444c89060d8.tar.zst nixlib-cc62bcb55359ba8c5e0fe3a48e778444c89060d8.zip |
Merge commit 'a323570a264da96a0b0bcc1c9aa017794acdc752'
Diffstat (limited to 'nixpkgs/pkgs/servers/prowlarr/update.sh')
-rwxr-xr-x | nixpkgs/pkgs/servers/prowlarr/update.sh | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/servers/prowlarr/update.sh b/nixpkgs/pkgs/servers/prowlarr/update.sh new file mode 100755 index 000000000000..d61edda5a0a3 --- /dev/null +++ b/nixpkgs/pkgs/servers/prowlarr/update.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p curl gnused nix-prefetch jq + +set -eou pipefail + +dirname="$(dirname "$0")" + +updateHash() +{ + version=$1 + arch=$2 + os=$3 + + hashKey="${arch}-${os}_hash" + + url="https://github.com/Prowlarr/Prowlarr/releases/download/v$version/Prowlarr.develop.$version.$os-core-$arch.tar.gz" + hash=$(nix-prefetch-url --type sha256 $url) + sriHash="$(nix hash to-sri --type sha256 $hash)" + + sed -i "s|$hashKey = \"[a-zA-Z0-9\/+-=]*\";|$hashKey = \"$sriHash\";|g" "$dirname/default.nix" +} + +updateVersion() +{ + sed -i "s/version = \"[0-9.]*\";/version = \"$1\";/g" "$dirname/default.nix" +} + +currentVersion=$(cd $dirname && nix eval --raw -f ../../.. prowlarr.version) + +# N.B. Prowlarr is still in development, so +# https://api.github.com/repos/Prowlarr/Prowlarr/releases/latest +# returns nothing. Once this endpoint returns something, we should use +# it. Until then, we use jq to sort releases (N.B. the "sort_by(. | +# split(".") | map(tonumber))" incantation is to sort the version +# number properly and not as a string). + +# latestTag=$(curl https://api.github.com/repos/Prowlarr/Prowlarr/releases/latest | jq -r ".tag_name") +# latestVersion="$(expr $latestTag : 'v\(.*\)')" +latestVersion=$(curl https://api.github.com/repos/Prowlarr/Prowlarr/git/refs/tags | jq '. | map(.ref | sub("refs/tags/v";"")) | sort_by(. | split(".") | map(tonumber)) | .[-1]' -r) + +if [[ "$currentVersion" == "$latestVersion" ]]; then + echo "Prowlarr is up-to-date: ${currentVersion}" + exit 0 +fi + +updateVersion $latestVersion + +updateHash $latestVersion x64 linux +updateHash $latestVersion arm64 linux +updateHash $latestVersion x64 osx |