Add ChangeLog for e656f34
[phpmyadmin.git] / scripts / set-version.sh
blob8d79a3414af329800d73c5ac9345fed5ca14e402
1 #!/bin/bash
3 # vim: expandtab sw=4 ts=4 sts=4:
5 # This requires Bash for the search and replace substitution to escape dots
7 # Do not run as CGI
8 if [ -n "$GATEWAY_INTERFACE" ] ; then
9 echo 'Can not invoke as CGI!'
10 exit 1
13 # Fail on undefined variables
14 set -u
15 # Fail on failure
16 set -e
18 printHelp () {
19 echo
20 echo "Please pass the new version number as a command line argument such as"
21 echo "$0 -v 5.0.0-dev"
22 echo
25 if [ $# -eq 0 ]
26 then
27 printHelp
28 exit 1
31 if [ "$1" = '-v' ]
32 then
33 newVersion=$2
34 else
35 printHelp
36 exit 2
39 # If we're in the scripts directory, we need to do all our work up a directory level
40 if [ "$(basename "$(pwd)")" = 'scripts' ]
41 then
42 dir='../'
43 else
44 dir=''
47 # There are half a dozen ways to do this, including individually recreating the line of
48 # each file (search for 'version =' in conf.py and replace it with 'version = 5.0.0-dev'
49 # for instance), and while that's more precise this should work with less to fix if a line changes.
50 # This method wasn't selected for any particular strength.
52 oldVersion="$(grep 'version =' ${dir}doc/conf.py | cut -d "'" -f2)"
54 echo "Changing from ${oldVersion} to ${newVersion}..."
56 # Escape the dot for sed
57 oldVersion=${oldVersion//./\.}
58 newVersion=${newVersion//./\.}
60 for f in README doc/conf.py libraries/classes/Config.php package.json
62 if ! grep --quiet "${oldVersion}" "${dir}${f}"
63 then
64 # There may be a better way to test for a failure of the substitution itself, such as using the 'q' directive with sed
65 # See https://stackoverflow.com/questions/15965073/return-code-of-sed-for-no-match
66 echo "FAILED! Substitution string ${oldVersion} not found in ${dir}${f}"
68 sed -i "s/${oldVersion}/${newVersion}/g" "${dir}${f}"
69 done
72 echo
73 echo "Next, you need to manually edit ChangeLog to manually change the version number and set the release date, and verify the changes with 'git diff'."
74 echo "Suggested commit message: Prepare for version ${newVersion}"