then echo "Bug in build_and_upload: $PACKAGE_FN doesn't point to a valid path"; exit 1
fi
set +x
echo "You are planning to upload '$PACKAGE_VERSION'."
read -rp "Is this correct? [y/n] " choice
if [ "$choice" != "y" ]
then echo "Aborting."; exit 1
fi
echo "Attempting to build $PACKAGE_VERSION from source"
TEMP_PATH=$(mktemp -d)
tar -xvf "$TGZ_LOC" -C "$TEMP_PATH"
set -x
(
cd "$TEMP_PATH/$PACKAGE_VERSION"
pwd
cabal v2-update
cabal v2-build --disable-optimization
)
set +x
if wget -q --spider "https://hackage.haskell.org/package/$PACKAGE_VERSION"
then
echo "The package $PACKAGE_VERSION already exists on Hackage."
echo "If you need to upload code changes, then bump the version number in $PROJECT/$PROJECT.cabal, make a PR, and run this script again."
echo "Otherwise, if you need _only_ to loosen existing constraints in $PROJECT.cabal file, then you can create a new revision of this package on Hackage."
echo "You'll need to make your changes by hand. Be sure to click the 'Review changes' button to check your work."
read -rp "Do you want to open a browser so as to do this? [y/N]" choice
if [ "$choice" == "y" ]
then
echo "Opening…"
sleep 1
open "https://hackage.haskell.org/package/$PACKAGE_VERSION/$PROJECT.cabal/edit"