nixpkgs/pkgs/by-name/ga/gancio/update.sh
Jean-Baptiste Giraudeau 0e639f2cc0
gancio: init at 1.19.0
Gancio is a shared agenda for local communities: https://gancio.org/
2024-09-06 16:32:06 +02:00

19 lines
954 B
Bash
Executable file

#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl common-updater-scripts jq nix prefetch-yarn-deps
set -eux -o pipefail
latest_version=$(curl -s https://framagit.org/api/v4/projects/48668/repository/tags | jq --raw-output '.[0].name' | sed 's/^v//')
nixFile=$(nix-instantiate --eval --strict -A "gancio.meta.position" | sed -re 's/^"(.*):[0-9]+"$/\1/')
nixFolder=$(dirname "$nixFile")
curl -o "$nixFolder/package.json" -s "https://framagit.org/les/gancio/-/raw/v$latest_version/package.json"
curl -o "$nixFolder/yarn.lock" -s "https://framagit.org/les/gancio/-/raw/v$latest_version/yarn.lock"
old_yarn_hash=$(nix-instantiate --eval --strict -A "gancio.offlineCache.outputHash" | tr -d '"' | sed -re 's|[+]|\\&|g')
new_yarn_hash=$(nix hash to-sri --type sha256 $(prefetch-yarn-deps "$nixFolder/yarn.lock"))
sed -i "$nixFile" -re "s|\"$old_yarn_hash\"|\"$new_yarn_hash\"|"
rm "$nixFolder/yarn.lock"
update-source-version gancio "$latest_version"