| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
# check to see if the software is ready for release |
| 4 |
# run this from the project root |
| 5 |
|
| 6 |
set -e |
| 7 |
|
| 8 |
if ! git status ; then |
| 9 |
exit 0 |
| 10 |
fi |
| 11 |
|
| 12 |
|
| 13 |
ROOT=`git rev-parse --show-toplevel` |
| 14 |
|
| 15 |
|
| 16 |
DIST=`cat "$ROOT/debian/changelog" | head -1 | awk '{print $3}' | sed -e 's/;//'` |
| 17 |
echo "The distribution for this release is $DIST" |
| 18 |
|
| 19 |
DEBVER=`cat "$ROOT/debian/changelog" | head -1 | sed -e 's/^[^\(]\+.//' | sed -e 's/\-.\+//'` |
| 20 |
echo "The changelog base version is $DEBVER" |
| 21 |
|
| 22 |
VER=`cat $ROOT/pyproject.toml | grep version | sed -e 's/\"//g' | awk '{print $NF}'` |
| 23 |
echo "The main version is $VER" |
| 24 |
|
| 25 |
TAG=`git describe HEAD` |
| 26 |
echo "The tag reported by 'git describe' is $TAG" |
| 27 |
|
| 28 |
TAGBRANCH=`echo "$TAG" | sed -e 's/\/.\+//'` |
| 29 |
echo "The branch for that is $TAGBRANCH" |
| 30 |
|
| 31 |
TAGVER=`echo "$TAG" | sed -e 's/^.\+\///' | sed -e 's/..$//'` |
| 32 |
echo "The tag base version is $TAGVER" |
| 33 |
|
| 34 |
echo |
| 35 |
|
| 36 |
fail="0" |
| 37 |
|
| 38 |
if [ "$DIST" == "UNRELEASED" ] ; then |
| 39 |
echo "Changelog is not released" |
| 40 |
fail="1" |
| 41 |
fi |
| 42 |
|
| 43 |
if [ "$DEBVER" != "$VER" ] ; then |
| 44 |
echo "Debian and upstream versions don't match" |
| 45 |
fail="1" |
| 46 |
fi |
| 47 |
|
| 48 |
if [ "$TAGBRANCH" != debian ] ; then |
| 49 |
echo "Debian release tag not found" |
| 50 |
fail="1" |
| 51 |
fi |
| 52 |
|
| 53 |
if [ "$TAGVER" != "$DEBVER" ] ; then |
| 54 |
echo "Tag version doesn't match debian base version" |
| 55 |
fail="1" |
| 56 |
fi |
| 57 |
|
| 58 |
found="0" |
| 59 |
for tag in `git tag --merged debian` ; do |
| 60 |
if [ "$tag" = "v$DEBVER" ] ; then |
| 61 |
found="1" |
| 62 |
fi |
| 63 |
done |
| 64 |
|
| 65 |
if [ $found = "0" ] ; then |
| 66 |
echo "Main tag not found in merge" |
| 67 |
fail="1" |
| 68 |
fi |
| 69 |
|
| 70 |
# This fails during build - patches run first |
| 71 |
# git diff-files --quiet || exit_code=$? |
| 72 |
# if (( exit_code == 1 )) ; then |
| 73 |
# echo "There are working tree changes" |
| 74 |
# fail="1" |
| 75 |
# fi |
| 76 |
|
| 77 |
if [ "$fail" == "1" ] ; then |
| 78 |
echo "ERROR ENCOUNTERED" |
| 79 |
if [[ "$TAGVER" =~ -.- ]] ; then # if this is not a release build |
| 80 |
/bin/true |
| 81 |
else |
| 82 |
exit 1 |
| 83 |
fi |
| 84 |
else |
| 85 |
echo "All checks successful" |
| 86 |
fi |
| 87 |
|
| 88 |
echo done |