Instantly share code, notes, and snippets.

What would you like to do?
Once I've manually tested a new build, I run this script to execute certain regression tests against it, then push it to my PAUSE account for indexing.
# This script is used to automate and move along the CPAN pipeline of
# module creation, and upload to CPAN.
set -e
function die {
echo "$1"
exit 1
if [ -e /tmp/$PID ]; then
die "The directory /tmp/$PID already exists - please remove it before proceding"
if [ ! -e Makefile.PL ]; then
die "This doesn't appear to be a Makefile.PL controlled module - Exiting"
# Register our cleanup trap
trap "rm -rf /tmp/$PID" EXIT
# Generate a distfile
echo "Generating distfile .."
perl Makefile.PL && make dist && make distclean || die 'Could not create distfile'
DISTFILE=$(ls -1rt *.tar.gz | tail -1)
mkdir -p /tmp/$PID/
mv $DISTFILE /tmp/$PID/
cd /tmp/$PID/
tar zxpvf $DISTFILE
DIRNAME=$( echo $DISTFILE | awk -F".tar.gz" '{print $1}' )
cd $DIRNAME || die "Could not cd to $DIRNAM"
fakeroot perl Makefile.PL && make test || die 'Failed regression tests'
echo "Uploading to PAUSE .."
make dist && cpan-upload $(cpan-upload-options) $(ls -1rt *.tar.gz | tail -1) || die 'Failed to upload to PAUSE'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment