• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env bash
2
3set -e
4
5PROGNAME="$(basename "${0}")"
6function usage() {
7cat <<EOF
8Usage:
9${PROGNAME} <next-version>
10
11This script merges 'develop' to 'master' and tags a release on the 'master'
12branch. It then bumps the version on 'develop' to the next planned version.
13<next-version> must be of the form X.Y.Z, where X, Y and Z are numbers.
14
15This script should be run from the root of the repository without any
16uncommitted changes.
17EOF
18}
19
20for arg in $@; do
21    if [[ "${arg}" == "-h" || "${arg}" == "--help" ]]; then
22        usage
23        exit 0
24    fi
25done
26
27if [[ $# -ne 1 ]]; then
28    echo "Missing the version"
29    usage
30    exit 1
31fi
32
33next_version="${1}"
34next_major="$(echo ${next_version} | cut -d '.' -f 1)"
35next_minor="$(echo ${next_version} | cut -d '.' -f 2)"
36next_patch="$(echo ${next_version} | cut -d '.' -f 3)"
37if [[ -z "${next_major}" || -z "${next_minor}" || -z "${next_patch}" ]]; then
38    echo "The version was specified incorrectly"
39    usage
40    exit 1
41fi
42
43current_major="$(sed -n -E 's/#define BOOST_HANA_MAJOR_VERSION ([0-9]+)/\1/p' include/boost/hana/version.hpp)"
44current_minor="$(sed -n -E 's/#define BOOST_HANA_MINOR_VERSION ([0-9]+)/\1/p' include/boost/hana/version.hpp)"
45current_patch="$(sed -n -E 's/#define BOOST_HANA_PATCH_VERSION ([0-9]+)/\1/p' include/boost/hana/version.hpp)"
46current_version="${current_major}.${current_minor}.${current_patch}"
47
48git checkout --quiet master
49git merge --quiet develop -m "Merging 'develop' into 'master' for ${current_version}"
50echo "Merged 'develop' into 'master' -- you should push 'master' when ready"
51
52tag="v${current_major}.${current_minor}.${current_patch}"
53git tag -a --file=RELEASE_NOTES.md "${tag}"
54echo "Created tag ${tag} on 'master' -- you should push it when ready"
55
56git checkout --quiet develop
57sed -i '' -E "s/#define BOOST_HANA_MAJOR_VERSION [0-9]+/#define BOOST_HANA_MAJOR_VERSION ${next_major}/" include/boost/hana/version.hpp
58sed -i '' -E "s/#define BOOST_HANA_MINOR_VERSION [0-9]+/#define BOOST_HANA_MINOR_VERSION ${next_minor}/" include/boost/hana/version.hpp
59sed -i '' -E "s/#define BOOST_HANA_PATCH_VERSION [0-9]+/#define BOOST_HANA_PATCH_VERSION ${next_patch}/" include/boost/hana/version.hpp
60cat <<EOF > RELEASE_NOTES.md
61Release notes for Hana ${next_version}
62============================
63EOF
64git add include/boost/hana/version.hpp RELEASE_NOTES.md
65git commit --quiet -m "Bump version of Hana to ${next_version} and clear release notes"
66echo "Bumped the version of Hana on 'develop' to ${next_version} -- you should push 'develop' when ready"
67