Skip to content

Instantly share code, notes, and snippets.

@bgamari
Last active October 31, 2015 17:38
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bgamari/4e03ad3e4bb3530d285f to your computer and use it in GitHub Desktop.
Save bgamari/4e03ad3e4bb3530d285f to your computer and use it in GitHub Desktop.
#!/bin/bash -e
name=$(sed -n -e 's/^[nN]ame:\s\+\(.\+\)/\1/p' *.cabal)
old_ver=$(sed -n -e 's/^[vV]ersion:\s\+\(.\+\)/\1/p' *.cabal)
has_docs=1
grep -i '^Library' *.cabal || has_docs=0
echo "Package name: $name"
echo "Current version: $old_ver"
echo "Has documentation: $has_docs"
read -p "New version [$old_ver]: " ver
if [ "$ver" != "" ]; then
sed -i -e "s/\(^[vV]ersion:\s\+\)$old_ver/\1$ver/" *.cabal
else
ver="$old_ver"
fi
cabal check
cabal clean
cabal configure --enable-tests
cabal build
cabal test
if [ $has_docs != 0 ]; then
cabal haddock --hyperlink-source \
--html-location='http://hackage.haskell.org/package/$pkg/docs' \
--contents-location='http://hackage.haskell.org/package/$pkg'
# Prepare documentation
cd dist/doc/html
dest="${name}-${ver}-docs"
cp -r "$name" "$dest"
tar -c -v -z --format=ustar -f "${dest}.tar.gz" "$dest"
cd ../../..
fi
echo
echo "Release looks good, let's ship it!"
if ! git diff --quiet *.cabal; then
git commit *.cabal -m "Bump to $ver" --edit
git tag v${ver}
git push origin master v${ver}
fi
cabal sdist
read -p "Hackage username: " username
read -s -p "Hackage password: " password
echo
#cabal upload --username $username --password $password dist/*-${ver}.tar.gz
# Upload documentation
if [ $has_docs != 0 ]; then
curl -X PUT -H 'Content-Type: application/x-tar' -H 'Content-Encoding: gzip' \
--data-binary "@dist/doc/html/${dest}.tar.gz" "http://${username}:${password}@hackage.haskell.org/package/${name}-${ver}/docs"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment