#!/bin/bash
usage() {
- echo "release.sh: VERSION"
+ echo "Usage: release.sh [-d] VERSION"
echo ""
echo "The script does all necessary steps to create a new release."
echo ""
+ echo " -d: no documentation update"
+ echo ""
echo "Note: The version number needs to be exactly"
- echo " '^v[\d]+.[\d]+(-rc[0-9]+)?$'"
+ echo " '^v[\d]+.[\d]+(.[\d\]+(-rc[0-9]+)?$'"
echo ""
echo "example:"
echo " release.sh v2.1-rc0 # v2.1 release candidate 0"
echo " release.sh v2.1 # v2.1 release"
}
-VERSION=$1
+build_doc=true
+
+while getopts "d" o; do
+ case "${o}" in
+ d)
+ build_doc=false
+ ;;
+ *)
+ usage
+ ;;
+ esac
+done
+shift $((OPTIND-1))
+
+VERSION=${1:-}
if [ -z "$VERSION" ] ; then
usage
ver=""
-re='^v([0-9]+\.[0-9]+)(-rc[0-9]+)?$'
+re='^v([0-9]+\.[0-9]+(\.[0-9]+)?)(-rc[0-9]+)?$'
if [[ "$VERSION" =~ $re ]]; then
echo "Valid version $VERSION string"
- ver=${BASH_REMATCH[1]}${BASH_REMATCH[2]}
+ # remove the leading 'v'
+ ver=${VERSION#v}
else
echo "Invalid version string $VERSION"
- echo ""
- usage
exit 1
fi
git add meson.build
git commit -s -m "build: Update version to $VERSION"
-# update documentation
-./$doc_dir/update-docs.sh
-git add $doc_dir
-git commit -s -m "doc: Regenerate all docs for $VERSION"
+if [ "$build_doc" = true ]; then
+ # update documentation
+ ./$doc_dir/update-docs.sh
+ git add $doc_dir
+ git commit -s -m "doc: Regenerate all docs for $VERSION"
+fi
git tag -s -m "Release $VERSION" "$VERSION"
git push --dry-run origin "$VERSION"^{}:master tag "$VERSION"