Add a script to update Version automatically
authorŁukasz Stelmach <l.stelmach@samsung.com>
Mon, 17 Nov 2014 15:04:16 +0000 (16:04 +0100)
committerŁukasz Stelmach <l.stelmach@samsung.com>
Wed, 19 Nov 2014 14:33:08 +0000 (15:33 +0100)
The script derives the package version from the upstream commit used as
a base for the package release. Proper upstream/ tag is also created.

Change-Id: I66987c225bb4a994c0312f4cf6a3f537cd8130f0
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
packaging/update_version.sh [new file with mode: 0644]

diff --git a/packaging/update_version.sh b/packaging/update_version.sh
new file mode 100644 (file)
index 0000000..4a8a6cc
--- /dev/null
@@ -0,0 +1,23 @@
+#!/bin/sh
+export TZ=UTC LANG=C
+cd $(dirname $0)
+
+upstream_base=$(git merge-base HEAD upstream/master)
+upstream_date=$(date +%Y%m%d.%H%M%S --date=@$(git log -1 --format=%at ${upstream_base}))
+upstream_short=$(git log -1 --format=%h ${upstream_base})
+KDBUS_VERSION=0.${upstream_date}utc
+
+if ! git tag -l upstream/* | grep ${KDBUS_VERSION}; then
+       git tag upstream/${KDBUS_VERSION} ${upstream_base}
+fi
+
+git stash
+if grep -q '^Version: \+'${KDBUS_VERSION} kdbus.spec; then
+       echo Package version is up to date.
+       git stash pop
+       exit 0;
+fi
+
+sed -i -e "1,/^Version: \+/s/^Version: \+[0-9].*/Version:    ${KDBUS_VERSION}/" kdbus.spec
+git commit -sam "Bump version to ${KDBUS_VERSION}"
+git stash pop