1#!/usr/bin/env nix-shell
2#!nix-shell -I nixpkgs=./. -i bash -p curl gnused jq yq nix bash coreutils nix-update
3
4set -eou pipefail
5
6ROOT="$(dirname "$(readlink -f "$0")")"
7
8latestTag=$(curl ${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} -sL https://api.github.com/repos/chen08209/FlClash/releases/latest | jq --raw-output .tag_name)
9latestVersion=$(echo "$latestTag" | sed 's/^v//')
10
11currentVersion=$(nix-instantiate --eval -E "with import ./. {}; flclash.version or (lib.getVersion flclash)" | tr -d '"')
12
13if [[ "$currentVersion" == "$latestVersion" ]]; then
14 echo "package is up-to-date: $currentVersion"
15 exit 0
16fi
17
18nix-update --subpackage libclash flclash
19
20curl https://raw.githubusercontent.com/chen08209/FlClash/${latestTag}/pubspec.lock | yq . >$ROOT/pubspec.lock.json