|
| 1 | +#!/bin/sh -- |
| 2 | +# |
| 3 | +# This script sets version number entries in various files in the BlocklyPropClient project. |
| 4 | +# Works in Ubuntu and OS X. |
| 5 | +# |
| 6 | +# Usage: $ ./set_version "1.2.3" |
| 7 | + |
| 8 | + |
| 9 | +# |
| 10 | +# Error if no version string declared |
| 11 | +# |
| 12 | +# if [ $1X == X ] <-- this doesn't work in Ubuntu |
| 13 | +if [ -z "$1" ] |
| 14 | +then |
| 15 | + echo "ERROR: Must specify a version number. Ex: \$ $0 \"1.2.3\"" |
| 16 | + exit 1 |
| 17 | +fi |
| 18 | + |
| 19 | + |
| 20 | +# |
| 21 | +# Get version string |
| 22 | +# |
| 23 | +VERSION=$1 |
| 24 | + |
| 25 | + |
| 26 | +# |
| 27 | +# FindAndSetVersion function |
| 28 | +# Find and update version string in form "Version = #.#.#" |
| 29 | +# Search is: case-insensitive, space, tabs, or nothing around '=', and one or more # in each placeholder. |
| 30 | +# Replace is: performed in-place inside of file; however, a backup (.bak) of the original file is also made. |
| 31 | +# |
| 32 | +# NOTE: sed on Mac doesn't include a case-insensitive option. To keep the search pattern equivalent for both |
| 33 | +# grep and sed, must use an expanded pattern for text where each letter is expressed in both upper/lower case. |
| 34 | +# ex: Ver should be [vV][eE][rR] |
| 35 | +# |
| 36 | +# function FindAndSetVersion { <-- this doesn't work in Ubuntu |
| 37 | +FindAndSetVersion() { |
| 38 | +if grep -q -E ${VERSIONPATTERN} ${VERSIONFILE} ; then |
| 39 | + if sed -i.bak -E "s/${VERSIONPATTERN}/${VERSIONSTRING}/" ${VERSIONFILE} ; then |
| 40 | + echo "Updated file \"${VERSIONFILE}\" to include: ${VERSIONSTRING}" |
| 41 | + fi |
| 42 | +else |
| 43 | + echo "ERROR: Unable to find version string in file \"${VERSIONFILE}\"" |
| 44 | +fi |
| 45 | +} |
| 46 | + |
| 47 | + |
| 48 | +# |
| 49 | +# Adjust BlocklyPropClient.py file - [format: VERSION = "#.#.#"] |
| 50 | +# |
| 51 | +VERSIONFILE=BlocklyPropClient.py |
| 52 | +VERSIONPATTERN=[vV][eE][rR][sS][iI][oO][nN][[:blank:]]*=[[:blank:]]*\"[0-9]+\.[0-9]+\.[0-9]+\" |
| 53 | +VERSIONSTRING="VERSION = \"${VERSION}\"" |
| 54 | + |
| 55 | +FindAndSetVersion |
| 56 | + |
| 57 | + |
| 58 | +# |
| 59 | +# Adjust about.txt file - [format: Version: v#.#.#] |
| 60 | +# |
| 61 | +VERSIONFILE=about.txt |
| 62 | +VERSIONPATTERN=[vV][eE][rR][sS][iI][oO][nN]:[[:blank:]]*v[[:blank:]]*[0-9]+\.[0-9]+\.[0-9]+ |
| 63 | +VERSIONSTRING="Version: v${VERSION}" |
| 64 | + |
| 65 | +FindAndSetVersion |
| 66 | + |
| 67 | + |
| 68 | +# |
| 69 | +# Adjust package/blocklypropclient-installer.iss file - [format: MyAppVersion "#.#.#"] |
| 70 | +# |
| 71 | +VERSIONFILE=package/blocklypropclient-installer.iss |
| 72 | +VERSIONPATTERN=[mM][yY][aA][pP][pP][vV][eE][rR][sS][iI][oO][nN][[:blank:]]+\"[0-9]+\.[0-9]+\.[0-9]+\" |
| 73 | +VERSIONSTRING="MyAppVersion \"${VERSION}\"" |
| 74 | + |
| 75 | +FindAndSetVersion |
0 commit comments