Skip to content

Commit

Permalink
Merge pull request #1923 from Andreea-L/refactor-debian-changelog-gen…
Browse files Browse the repository at this point in the history
…eration

tools: Refactor changelog generation
  • Loading branch information
julianoes authored Nov 2, 2022
2 parents 9177ef0 + 1838049 commit 9700463
Showing 1 changed file with 62 additions and 11 deletions.
73 changes: 62 additions & 11 deletions tools/generate_debian_changelog.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,71 @@
#!/usr/bin/env bash

# We want to extract "1.2.3" from "v1.2.3-5-g123abc".
tag_version=`git describe --always --tags | sed 's/v\([0-9]*\.[0-9]*\.[0-9]*\).*$/\1/'`
set -e

# Default to 1 for package version
if [ "$#" == 1 ]; then
package_version=$1
# Date according to RFC 5322
DATE=$(date -R)
AUTHOR="MAVSDK Team"
EMAIL=""
PRE_RELEASE=1

# Fetch tags from upstream in case they're not synced
git fetch --tags

# Get the tag which points to the current commit hash; if the current commit is not tagged, the version core defaults to the current hash
CURRENT_REF="$(git rev-parse --short HEAD)"
CURRENT_TAG=$(git tag --points-at "$CURRENT_REF" | sed 's/v\([0-9]*\.[0-9]*\.[0-9]*\).*$/\1/')
if [ ! -z "$CURRENT_TAG" ]; then
VERSION=$CURRENT_TAG
else
package_version="1"
# dpkg-buildpacakge expects the version to start with a digit, hence the 0
VERSION="0v$CURRENT_REF"
fi

# Date according to RFC 5322
date=`date -R`
function usage() {
cat << EOF
Usage:
$0 <options ...>
--version <version core; default=0v[CURRENT_REF] or [CURRENT_TAG]>
--pre <pre-release number; default=1>
--author <author name; default=MAVSDK Team>
--email <author email; default=[empty]>
Examples:
./generate_debian_changelog.sh
--version=1.0.0
--pre=1
--author="Example Name"
--email="mavsdk@example.com"
EOF
}

function usage_and_exit() {
usage
exit $1
}

for i in "$@"
do
case $i in
--version=*)
VERSION="${i#*=}"
;;
--pre=*)
PRE_RELEASE="${i#*=}"
;;
--author=*)
AUTHOR="${i#*=}"
;;
--email=*)
EMAIL="${i#*=}"
;;
*) # unknown option
usage_and_exit 1
;;
esac
done

echo "mavsdk ($tag_version-$package_version) unstable; urgency=medium"
echo "mavsdk ($VERSION-$PRE_RELEASE) unstable; urgency=medium"
echo ""
echo " * Initial release"
echo " * MAVSDK release"
echo ""
echo " -- Helge Bahmann <helge@auterion.com> $date"
echo " -- $AUTHOR <$EMAIL> $DATE"

0 comments on commit 9700463

Please sign in to comment.