Skip to content

Instantly share code, notes, and snippets.

@svalaskevicius
Forked from Fuuzetsu/hackagedocs
Last active August 29, 2015 14:07
Show Gist options
  • Save svalaskevicius/684325189b96b1496a0d to your computer and use it in GitHub Desktop.
Save svalaskevicius/684325189b96b1496a0d to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
PACKAGE="$1"
VERSION="$(cat "$1.cabal" | grep -e '^version:[0-9 \.]*$' | sed -e 's/^version:\s*\([0-9\.]*\)\s*$/\1/')"
if test -z "$VERSION" ; then
echo "version not found."
exit 1
fi
if echo "$VERSION" | grep -e '[^0-9\.]' ; then
echo "version format is invalid found: $VERSION"
exit 1
fi
cabal configure && cabal build && cabal haddock --hyperlink-source \
--html-location='/package/$pkg-$version/docs' \
--contents-location='/package/$pkg' \
--hoogle
S=$?
if [ "${S}" -eq "0" ]; then
cd "dist/doc/html"
DDIR="${PACKAGE}-${VERSION}-docs"
cp -r "${PACKAGE}" "${DDIR}" && tar -c -v -z --format=ustar -f "${DDIR}.tar.gz" "${DDIR}"
CS=$?
if [ "${CS}" -eq "0" ]; then
echo "Uploading to Hackage…"
echo -n Username:
read username
echo -n Password:
read -s password
echo
curl -X PUT -H 'Content-Type: application/x-tar' -H 'Content-Encoding: gzip' --data-binary "@${DDIR}.tar.gz" "https://${username}:${password}@hackage.haskell.org/package/${PACKAGE}-${VERSION}/docs"
exit $?
else
echo "Error when packaging the documentation"
exit $CS
fi
else
echo "Error when trying to build the package."
exit $S
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment