• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2
3if [ "$#" -ne 2 ]
4  then
5    echo "Use: ./bump-version old_version new_version"
6    exit
7fi
8
9old_version=$1
10new_version=$2
11
12update_version() {
13    echo "Updating version from '$old_version' to '$new_version' in $1"
14    sed -i.bak s/$old_version/$new_version/g $1
15    rm $1.bak
16}
17
18update_version "README.md"
19update_version "gradle.properties"
20
21# Escape dots, e.g. 1.0.0 -> 1\.0\.0
22escaped_old_version=$(echo $old_version | sed s/[.]/\\\\./g)
23result=$(find ./ -type f \( -iname \*.properties -o -iname \*.md \) | grep -v "\.gradle" | grep -v "build" | xargs -I{} grep -H "$escaped_old_version" {} | grep -v CHANGES.md)
24if [ -z "$result" ];
25then
26    echo "Done"
27else
28    echo "ERROR: Previous version is present in the project: $result"
29    exit -1
30fi
31