-
Notifications
You must be signed in to change notification settings - Fork 2
/
_build_local.sh
executable file
·65 lines (52 loc) · 2.05 KB
/
_build_local.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env bash
set -e
echo "============================================================"
echo "Hypernode Nginx Config Reloader Development Build"
echo " - Will build package from a temp Git branch"
echo " - Will NOT tag the build"
echo " - Will NOT push anything"
echo "============================================================"
ARCH="${ARCH:-amd64}"
DIST="${DIST:-xenial}"
BUILDAREA="${BUILDAREA:-/tmp/nginx-config-reloader-build}"
BUILDPATH="${BUILDAREA}-${DIST}"
CURRENT_BRANCH=`git rev-parse --abbrev-ref HEAD`
if [ -z "$BRANCH" ]; then
BRANCH="$CURRENT_BRANCH"
fi
export VERSION=$(date "+%Y%m%d.%H%M%S")
git checkout $BRANCH
TEMPBRANCH="$BRANCH-build-$DIST-$VERSION"
git checkout -b $TEMPBRANCH
echo "Updating setup.py with version $VERSION"
perl -pi -e 's/version="[^"]*",/version=\"$ENV{"VERSION"}\",/g;' setup.py
echo "Adding setup.py to git index"
git add setup.py
echo "Committing setup.py version update"
git commit setup.py -m "Update version in setup.py to $VERSION"
echo "Generating changelog changelog"
gbp dch --debian-tag="%(version)s" --new-version=$VERSION --debian-branch $TEMPBRANCH --release --commit
echo "Building package for $DIST"
mkdir -p $BUILDPATH
gbp buildpackage --git-pbuilder --git-export-dir=$BUILDPATH --git-dist=$DIST --git-arch=$ARCH \
--git-debian-branch=$TEMPBRANCH --git-ignore-new
echo
echo "*************************************************************"
echo "Package built succesfully!"
echo "--> ${BUILDPATH}/nginx-config-reloader_${VERSION}_all.deb"
echo
echo "Checking out original branch ..."
git checkout $BRANCH
if [ -z "${KEEP_TEMPBRANCH}" ]; then
echo "Removing temp Git branch "$TEMPBRANCH" ... (to avoid this set KEEP_TEMPBRANCH env variable)"
git branch -D $TEMPBRANCH
echo ""
echo "You can clear things up by"
echo "------------------------------------------------------------"
echo "rm -rf ${BUILDPATH}"
else
echo "You can clear things up by"
echo "------------------------------------------------------------"
echo "git branch -D ${TEMPBRANCH}"
echo "rm -rf ${BUILDPATH}"
fi