From e112bd283f9b8bbc4831cb6ed3670ce160ca835b Mon Sep 17 00:00:00 2001 From: Andreea-L Date: Wed, 2 Nov 2022 16:47:22 +0100 Subject: [PATCH 1/2] tools: Refactor changelog generation --- tools/generate_debian_changelog.sh | 73 +++++++++++++++++++++++++----- 1 file changed, 62 insertions(+), 11 deletions(-) diff --git a/tools/generate_debian_changelog.sh b/tools/generate_debian_changelog.sh index f63be855b4..a361dba868 100755 --- a/tools/generate_debian_changelog.sh +++ b/tools/generate_debian_changelog.sh @@ -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 + --version + --pre + --author + --email + 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 " * Auterion MAVSDK release" echo "" -echo " -- Helge Bahmann $date" +echo " -- $AUTHOR <$EMAIL> $DATE" From 1838049de02eb23e6afd15b6896cf17ee066c871 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreea=20Lu=C8=9Bac?= Date: Wed, 2 Nov 2022 16:01:41 +0000 Subject: [PATCH 2/2] Update tools/generate_debian_changelog.sh Co-authored-by: Jonas Vautherin --- tools/generate_debian_changelog.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/generate_debian_changelog.sh b/tools/generate_debian_changelog.sh index a361dba868..31d9447b88 100755 --- a/tools/generate_debian_changelog.sh +++ b/tools/generate_debian_changelog.sh @@ -66,6 +66,6 @@ done echo "mavsdk ($VERSION-$PRE_RELEASE) unstable; urgency=medium" echo "" -echo " * Auterion MAVSDK release" +echo " * MAVSDK release" echo "" echo " -- $AUTHOR <$EMAIL> $DATE"