Commit 999400d4 authored by nayeko's avatar nayeko
Browse files

gopeed: add update script

parent 2c678667
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -68,6 +68,8 @@ flutter324.buildFlutterApplication {
    install -Dm644 assets/icon/icon_1024.png $out/share/icons/hicolor/1024x1024/apps/com.gopeed.Gopeed.png
  '';

  passthru.updateScript = ./update.sh;

  meta = metaCommon // {
    mainProgram = "gopeed";
  };
+20 −0
Original line number Diff line number Diff line
#!/usr/bin/env nix-shell
#!nix-shell -I nixpkgs=./. -i bash -p curl gnused jq yq nix bash coreutils nix-update

set -eou pipefail

ROOT="$(dirname "$(readlink -f "$0")")"

latestTag=$(curl ${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} -sL https://api.github.com/repos/GopeedLab/gopeed/releases/latest | jq --raw-output .tag_name)
latestVersion=$(echo "$latestTag" | sed 's/^v//')

currentVersion=$(nix-instantiate --eval -E "with import ./. {}; gopeed.version or (lib.getVersion gopeed)" | tr -d '"')

if [[ "$currentVersion" == "$latestVersion" ]]; then
    echo "package is up-to-date: $currentVersion"
    exit 0
fi

nix-update gopeed.libgopeed

curl https://raw.githubusercontent.com/GopeedLab/gopeed/${latestTag}/ui/flutter/pubspec.lock | yq . >$ROOT/pubspec.lock.json