#!/usr/bin/env bash
set -x
USER=drush-ops
PROJECT=drush-launcher
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/${USER}/${PROJECT}/releases/download/"${RELEASE}"/drush.phar
chmod +x drush.phar &&
	mv drush.phar /usr/local/bin/drush
