gopeed: add update script

nayeko 999400d4 2c678667

+22
+2
pkgs/by-name/go/gopeed/package.nix
··· 68 install -Dm644 assets/icon/icon_1024.png $out/share/icons/hicolor/1024x1024/apps/com.gopeed.Gopeed.png 69 ''; 70 71 meta = metaCommon // { 72 mainProgram = "gopeed"; 73 };
··· 68 install -Dm644 assets/icon/icon_1024.png $out/share/icons/hicolor/1024x1024/apps/com.gopeed.Gopeed.png 69 ''; 70 71 + passthru.updateScript = ./update.sh; 72 + 73 meta = metaCommon // { 74 mainProgram = "gopeed"; 75 };
+20
pkgs/by-name/go/gopeed/update.sh
···
··· 1 + #!/usr/bin/env nix-shell 2 + #!nix-shell -I nixpkgs=./. -i bash -p curl gnused jq yq nix bash coreutils nix-update 3 + 4 + set -eou pipefail 5 + 6 + ROOT="$(dirname "$(readlink -f "$0")")" 7 + 8 + latestTag=$(curl ${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} -sL https://api.github.com/repos/GopeedLab/gopeed/releases/latest | jq --raw-output .tag_name) 9 + latestVersion=$(echo "$latestTag" | sed 's/^v//') 10 + 11 + currentVersion=$(nix-instantiate --eval -E "with import ./. {}; gopeed.version or (lib.getVersion gopeed)" | tr -d '"') 12 + 13 + if [[ "$currentVersion" == "$latestVersion" ]]; then 14 + echo "package is up-to-date: $currentVersion" 15 + exit 0 16 + fi 17 + 18 + nix-update gopeed.libgopeed 19 + 20 + curl https://raw.githubusercontent.com/GopeedLab/gopeed/${latestTag}/ui/flutter/pubspec.lock | yq . >$ROOT/pubspec.lock.json