Last active
August 29, 2015 14:20
-
-
Save fliphess/cb776a2ed0ab82c193f2 to your computer and use it in GitHub Desktop.
Release and build a debian or ubuntu package using git-buildpackage and pbuilder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
TAG="$1" | |
TIMESTAMP="$(date "+%Y%m%d.%H%M%S")" | |
BRANCH="$( git branch | awk '{ print $NF }' )" | |
## If this is a development build, then set tag depending on last tag +1 | |
if [ "${BRANCH}" == "develop" ] ; then | |
TAG="$( git tag -l | tail -n 1 )1" | |
fi | |
## Check for tag | |
if [ "x$TAG" == "x" ] || [ -z "$TAG" ] ; then | |
echo "Usage: $0 <tag>" | |
exit 0 | |
fi | |
## Set version depending on branch | |
export VERSION="${TAG}+${TIMESTAMP}" | |
if [ "${BRANCH}" == "develop" ] ; then | |
export VERSION="${TAG}+${TIMESTAMP}-development" | |
fi | |
## Get all commits since last tag and adapt changelog accordingly | |
echo Updating changelog | |
git-dch --debian-tag="%(version)s" --new-version=$VERSION --debian-branch $BRANCH --release | |
## Put changelog in git | |
echo Committing changelog | |
git add debian/changelog | |
git commit -m "Annotate changelog" | |
## Create tag and push | |
echo Tagging current version | |
git tag $VERSION | |
git push | |
git push --tags | |
## Run a package build | |
echo Building package | |
git-buildpackage --git-pbuilder --git-dist=unstable --git-arch=amd64 --git-ignore-branch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment