39 lines
1.1 KiB
Bash
Executable file
39 lines
1.1 KiB
Bash
Executable file
#!/usr/bin/env nix-shell
|
|
#!nix-shell -i bash -p curl gnused nix-prefetch jq
|
|
|
|
dirname="$(dirname "$0")"
|
|
|
|
updateHash()
|
|
{
|
|
version=$1
|
|
arch=$2
|
|
os=$3
|
|
|
|
hashKey="${arch}-${os}_hash"
|
|
url="https://github.com/Ombi-app/Ombi/releases/download/v$version/$os-$arch.tar.gz"
|
|
hash="$(nix-prefetch-url $url)"
|
|
|
|
sed -i "s|$hashKey = \"[a-zA-Z0-9\/+-=]*\";|$hashKey = \"$hash\";|g" "$dirname/default.nix"
|
|
}
|
|
|
|
updateVersion()
|
|
{
|
|
sed -i "s/version = \"[0-9.]*\";/version = \"$1\";/g" "$dirname/default.nix"
|
|
}
|
|
|
|
oldversion="$(grep -Po '(?<=version = ").*(?=";)' default.nix)"
|
|
newversion="$(curl -s -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/Ombi-App/Ombi/releases | jq -r ".[0].tag_name" | sed "s/^v//")"
|
|
version="$newversion"
|
|
|
|
if [[ "$oldversion" == "$newversion" ]]; then
|
|
echo "Ombi is up 2 date: Version $oldversion"
|
|
exit 0
|
|
fi
|
|
|
|
updateVersion $newversion
|
|
|
|
updateHash $newversion x64 linux
|
|
updateHash $newversion arm64 linux
|
|
updateHash $newversion x64 osx
|
|
|
|
git pull && git add "$dirname"/default.nix && git commit -m "updated ombi from $oldversion to $newversion" && git push
|