depot/third_party/nixpkgs/pkgs/servers/monitoring/uchiwa/update.sh
Default email 8ac5e011d6 Project import generated by Copybara.
GitOrigin-RevId: 2c3273caa153ee8eb5786bc8141b85b859e7efd7
2020-04-24 19:36:52 -04:00

42 lines
878 B
Bash
Executable file

#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl.bin git.out nix jq.out nodePackages.bower2nix
set -euo pipefail
IFS=$'\n\t'
# set -x
REPO=sensu/uchiwa
VERSION=0.0.1
SHA="1111111111111111111111111111111111111111111111111111"
DIR=$(pwd)
write_src() {
cat <<_EOF > $DIR/src.nix
{
version = "${VERSION}";
sha256 = "${SHA}";
}
_EOF
}
LATEST_VERSION=$(curl https://api.github.com/repos/${REPO}/tags -s | jq '.[0]' -r | jq .name -r)
echo "Latest version: ${LATEST_VERSION}"
VERSION=${1:-${LATEST_VERSION}}
echo "Updating to: ${VERSION}"
TOP=$(git rev-parse --show-toplevel)
cd $(dirname $0)
write_src
pushd $TOP >/dev/null
SHA=$(nix-prefetch-url -A uchiwa.src)
popd >/dev/null
write_src
curl https://raw.githubusercontent.com/${REPO}/${VERSION}/bower.json -s > bower.json
rm -f bower-packages.nix
bower2nix bower.json $DIR/bower-packages.nix
rm -f bower.json