#!/usr/bin/env bash

USER=alhoo
PROJECT=jf
#RELEASE=$(curl --silent "https://api.github.com/repos/${PROJECT}/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
RELEASE=$(curl "https://api.github.com/repos/${USER}/${PROJECT}/tags?per_page=5" | jq -r '.[0] | .name')
JF_BUILD_HOME=/var/tmp/python-jf-"${RELEASE}"

mkdir -p "${JF_BUILD_HOME}" && cd "${JF_BUILD_HOME}" || exit
echo "JF, is a jq-clone written in python. It supports evaluation of python oneliners, making it especially appealing for data scientists who are used to working with python." >description-pak
mkdir -p doc-pak && wget -c --directory-prefix doc-pak https://raw.githubusercontent.com/${USER}/${PROJECT}/develop/README.rst
sudo checkinstall --fstrans=no pip install -U http://github.com/${USER}/${PROJECT}/archive/"${RELEASE}".zip
