This script is quite useful to test Debian packaging and build against the master of a project.
I use it to develop the packaging in my debian branch and pull the latest master from the projects' repo.
#!/bin/bash
set -e
set -x
VERSION="0.8.19"
BUILD_NUMBER="1337"
[ -d tmpbuilddir ] && rm -rf tmpbuilddir
mkdir tmpbuilddir
cd tmpbuilddir
git clone https://github.com/reox/libelektra -b master
cd libelektra
git remote add upstream https://github.com/ElektraInitiative/libelektra.git
git fetch upstream master
git merge --no-ff -m "merge $VERSION" upstream/master
git tag -f $VERSION
git checkout -b debian origin/debian
git merge --no-ff -m "merge $VERSION" master
dch -l ".$BUILD_NUMBER" "auto build"
git commit -am "auto build $VERSION"
git archive --format=tar HEAD | gzip > ../elektra_$VERSION.orig.tar.gz
annotate-output +"%H:%M:%S.%N" dpkg-buildpackage -sa | tee ~/buildlog.log