aboutsummaryrefslogtreecommitdiff
path: root/pkgs/servers/monitoring/uchiwa/update.sh
blob: 10da7f8adbf934dc748a02575e03586a0347e93c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/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