From e66c8c9a96fa2ba93bae1ce3c3a73f5126f0a48f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Rodr=C3=ADguez?= Date: Wed, 4 Mar 2015 13:34:24 +0000 Subject: [PATCH] Add bumpversion script --- .bumpversion.sh | 105 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100755 .bumpversion.sh diff --git a/.bumpversion.sh b/.bumpversion.sh new file mode 100755 index 0000000..4eccf7f --- /dev/null +++ b/.bumpversion.sh @@ -0,0 +1,105 @@ +#!/bin/sh +# +# Copyright 2013-2015 Telefónica I+D +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# + + +# +# Update version strings using bumpversion package (run 'pip' to install) +# +# Usage: .bumpversion.sh [bumpversion options ...] +# See: https://pypi.python.org/pypi/bumpversion +# + + +# Files to be updated +ADAPTER_CONF=ngsi_adapter/src/package.json +BROKER_CONF=ngsi_event_broker/configure.ac + +# Additional bumpversion options +BUMPVERSION_OPTS="$*" + +# Check whether pip tool is installed +which pip >/dev/null || { + printf "Cannot find pip command\n\n" 1>&2 + exit 1 +} + +# Check whether bumpversion package is installed +which bumpversion >/dev/null || { + printf "Please run \`pip install bumpversion' to use this tool\n\n" 1>&2 + exit 1 +} + +# Ask for new FIWARE release +CUR_RELEASE=$(awk -F'[ :]' '/_FIWARE.*release/ {print $3; exit}' README.rst) +PROMPT="Please specify new FIWARE release (current is $CUR_RELEASE): " +read -p "$PROMPT" NEW_RELEASE +test -n "$NEW_RELEASE" || { + printf "ERROR: A release number x.y.z must be supplied\n\n" 1>&2 + exit 2 +} + +# Ask for new NGSI Adapter version +CUR_ADAPTER_VER=$(awk -F'"' '/"version"/ {print $4}' $ADAPTER_CONF) +PROMPT="Please specify new NGSI Adapter version (current is $CUR_ADAPTER_VER): " +read -p "$PROMPT" NEW_ADAPTER_VER +test -n "$NEW_ADAPTER_VER" || { + printf "ERROR: A version number x.y.z must be supplied\n\n" 1>&2 + exit 2 +} + +# Ask for new Event Broker version +CUR_BROKER_VER=$(sed -n '/AC_INIT/ {s/.*,[ \t]*\(.*\))/\1/; p}' $BROKER_CONF) +PROMPT="Please specify new Event Broker version (current is $CUR_BROKER_VER): " +read -p "$PROMPT" NEW_BROKER_VER +test -n "$NEW_BROKER_VER" || { + printf "ERROR: A version number x.y.z must be supplied\n\n" 1>&2 + exit 2 +} + +# Abort on error +set -e + +# Update release and version in NGSI Adapter configuration files +bumpversion --commit --no-tag \ + --current-version=$CUR_RELEASE --new-version=$NEW_RELEASE \ + --search='"release": "{current_version}"' \ + --replace='"release": "{new_version}"' \ + --message='Bump product release: {current_version} -> {new_version}' \ + $BUMPVERSION_OPTS patch $ADAPTER_CONF + +bumpversion --commit --no-tag \ + --current-version=$CUR_ADAPTER_VER --new-version=$NEW_ADAPTER_VER \ + --search='"version": "{current_version}"' \ + --replace='"version": "{new_version}"' \ + --message='Bump component version: {current_version} -> {new_version}' \ + $BUMPVERSION_OPTS patch $ADAPTER_CONF + +# Update release and version in Event Broker configuration files +bumpversion --commit --no-tag \ + --current-version=$CUR_RELEASE --new-version=$NEW_RELEASE \ + --search='[PRODUCT_RELEASE], [{current_version}]' \ + --replace='[PRODUCT_RELEASE], [{new_version}]' \ + --message='Bump product release: {current_version} -> {new_version}' \ + $BUMPVERSION_OPTS patch $BROKER_CONF + +bumpversion --commit --no-tag \ + --current-version=$CUR_BROKER_VER --new-version=$NEW_BROKER_VER \ + --search='AC_INIT([PRODUCT_NAME-ngsi-event-broker], {current_version})'\ + --replace='AC_INIT([PRODUCT_NAME-ngsi-event-broker], {new_version})' \ + --message='Bump component version: {current_version} -> {new_version}' \ + $BUMPVERSION_OPTS patch $BROKER_CONF