#!/usr/bin/env bash
apt install -y jq

set -x
USER=onivim
PROJECT=oni
RELEASE=$(curl "https://api.github.com/repos/${USER}/${PROJECT}/releases?per_page=5" | jq -r '.[0] | .tag_name')
VERSION=$(echo "${RELEASE}" | cut -c 2- | cut -f1 -d"-")
DOWNLOAD_DIR=/tmp

RSS_FEED="https://github.com/${USER}/${PROJECT}/releases.atom"
# xdg-open ${RSS_FEED}
echo ${RSS_FEED}

wget -c --directory-prefix "${DOWNLOAD_DIR}" http://github.com/onivim/oni/releases/download/"${RELEASE}"/Oni-"${VERSION}"-amd64-linux.deb

sudo dpkg -i "${DOWNLOAD_DIR}/Oni-${VERSION}-amd64-linux.deb"
