Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

executable file 105 lines (76 sloc) 2.578 kB
#!/bin/bash
#
if [ "$(git branch | grep '* ')" != "* master" ]; then
echo "You are not on the master branch!"
exit 1
fi
echo "Have you updated the version number? Type 'yes' if you have!"
read version_response
if [ "$version_response" != "yes" ]; then
echo "Go and update the version number"
exit 1
fi
# Not 'example' as well because we don't really want to upload a simple example package to Hackage.
declare -a subdirectories=(core hunit quickcheck quickcheck2)
declare -a filenames
index=0
while [ "$index" -lt "${#subdirectories[@]}" ]; do
# Find out the working subdirectory and enter it
subdirectory=${subdirectories[index]}
cd $subdirectory
# For those directories that use CPP, we need to configure before sdist will work without a warning
runghc Setup.lhs configure --user
# OK, build the tarball
sdist_output=`runghc Setup.lhs sdist`
if [ "$?" != "0" ]; then
echo "Cabal sdist failed, aborting"
exit 1
fi
# Want to find a line like:
# Source tarball created: dist/ansi-terminal-0.1.tar.gz
# Test this with:
# runghc Setup.lhs sdist | grep ...
filename=`echo $sdist_output | sed 's/.*Source tarball created: \([^ ]*\).*/\1/'`
filenames[$index]="$subdirectory/$filename"
echo "Filename: $filename"
if [ "$filename" = "$sdist_output" ]; then
echo "Could not find filename, aborting"
exit 1
fi
if [ "$subdirectory" = "core" ]; then
# Test this with:
# echo dist/ansi-terminal-0.1.tar.gz | sed ...
version=`echo $filename | sed 's/^[^0-9]*\([0-9\.]*\).tar.gz$/\1/'`
echo "Version: $version"
if [ "$version" = "$filename" ]; then
echo "Could not find version, aborting"
exit 1
fi
fi
# Move to the next directory
cd ..
let "index = $index + 1"
done
echo "This is your last chance to abort! I'm going to upload v$version in 10 seconds"
sleep 10
if [ -n "$version" ]; then
git tag "v$version"
if [ "$?" != "0" ]; then
echo "Git tag failed, aborting"
exit 1
fi
fi
index=0
while [ "$index" -lt "${#filenames[@]}" ]; do
# You need to have stored your Hackage username and password as directed by cabal-upload
# I use -v5 because otherwise the error messages can be cryptic :-)
filename=${filenames[index]}
cabal upload -v3 $filename
if [ "$?" != "0" ]; then
echo "Hackage upload of $filename failed, aborting"
exit 1
fi
let "index = $index + 1"
done
# Success!
exit 0
Jump to Line
Something went wrong with that request. Please try again.