[libcamera-devel,v2,5/5] utils: Provide a release script
diff mbox series

Message ID 20220930232826.82753-6-kieran.bingham@ideasonboard.com
State Superseded
Headers show
Series
  • Add release infrastructure
Related show

Commit Message

Kieran Bingham Sept. 30, 2022, 11:28 p.m. UTC
Support making releases of libcamera by introducing a helper script
which will facilitate the increment of any release version, along with
generating an associated tag.

Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

---
This can later be extended to support or enforce adding an overview
changelog to the commit, and annotated tag.

 utils/release.sh | 45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)
 create mode 100755 utils/release.sh

Patch
diff mbox series

diff --git a/utils/release.sh b/utils/release.sh
new file mode 100755
index 000000000000..13df8457eaa2
--- /dev/null
+++ b/utils/release.sh
@@ -0,0 +1,45 @@ 
+#!/bin/sh
+
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Prepare a project release
+
+# Abort if we are not within the project root or the tree is not clean.
+if [ ! -e utils/gen-version.sh ] || [ ! -e .git ]; then
+	echo "This release script must be run from the root of libcamera git clone."
+	exit 1
+fi
+
+if ! git diff-index --quiet HEAD; then
+	echo "Tree must be clean to release."
+	exit 1
+fi
+
+# Identify current version components
+version=$(./utils/gen-version.sh)
+
+# Decide if we are here to bump major, minor, or patch release.
+case $1 in
+	major|minor|patch)
+		bump=$1;
+		;;
+	*)
+		echo "You must specify the version bump level: (major, minor, patch)"
+		exit 1
+		;;
+esac
+
+new_version=$(./utils/semver bump "$bump" "$version")
+
+echo "Bumping $bump"
+echo "  Existing version is: $version"
+echo "  New version is : $new_version"
+
+# Patch in the version to our meson.build
+sed -i -E "s/ version : '.*',/ version : '$new_version',/" meson.build
+
+# Commit the update
+git add meson.build
+git commit meson.build -sm "libcamera v$new_version"
+
+# Create a tag
+git tag "v$new_version" -asm "libcamera v$new_version"