#!/usr/bin/env nix-shell #!nix-shell -i bash -p curl jq git moreutils yarn2nix nix nix-prefetch set -euo pipefail BASE_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) cd "${BASE_DIR}" json_get() { jq -r "$1" < 'meta.json' } json_set() { jq --arg x "$2" "$1 = \$x" < 'meta.json' | sponge 'meta.json' } # Frontend old_frontend_rev=$(json_get '.frontend.rev') new_frontend_rev=$(curl -L "https://api.github.com/repos/TeamPiped/Piped/commits" 2>/dev/null | jq ".[0].sha" -r) if [ "$new_frontend_rev" != "$old_frontend_rev" ]; then echo "Frontend is out of date. Updating..." json_set '.frontend.rev' "$new_frontend_rev" #new_frontend_sha256=$(nix-prefetch fetchFromGitHub --owner TeamPiped --repo Piped --rev "$new_frontend_rev") #json_set '.frontend.sha256' "$new_frontend_sha256" #TMP=$(mktemp -d) #pushd "$TMP" # git clone https://github.com/TeamPiped/Piped # pushd Piped # git reset --hard "$new_frontend_rev" # yarn2nix > "${BASE_DIR}/frontend/yarn.nix" # popd #popd fi # Backend old_backend_rev=$(json_get '.backend.rev') new_backend_rev=$(curl -L "https://api.github.com/repos/TeamPiped/Piped-Backend/commits" 2>/dev/null | jq ".[0].sha" -r) if [ "$new_backend_rev" != "$old_backend_rev" ]; then echo "Backend is out of date. Updating..." json_set '.backend.rev' "$new_backend_rev" #new_backend_sha256=$(nix-prefetch fetchFromGitHub --owner TeamPiped --repo Piped-Backend --rev "$new_backend_rev") #json_set '.backend.sha256' "$new_backend_sha256" fi # Proxy old_proxy_rev=$(json_get '.proxy.rev') new_proxy_rev=$(curl -L "https://api.github.com/repos/TeamPiped/piped-proxy/commits" 2>/dev/null | jq ".[0].sha" -r) if [ "$new_proxy_rev" != "$old_proxy_rev" ]; then echo "Proxy is out of date. Updating..." json_set '.proxy.rev' "$new_proxy_rev" #new_proxy_sha256=$(nix-prefetch fetchFromGitHub --owner TeamPiped --repo piped-proxy --rev "$new_proxy_rev") #json_set '.proxy.sha256' "$new_proxy_sha256" fi