-
-
Notifications
You must be signed in to change notification settings - Fork 520
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1923 from Andreea-L/refactor-debian-changelog-gen…
…eration tools: Refactor changelog generation
- Loading branch information
Showing
1 changed file
with
62 additions
and
11 deletions.
There are no files selected for viewing
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
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" |