Translated using Weblate (Portuguese)
[phpmyadmin.git] / bin / internal / set-version.sh
blobeffb49642790cc5f72bcddece5c84442ddabc587
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)")" = 'bin' ]
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}"docs/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 docs/conf.py 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
71 echo
72 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'."
73 echo "- You will probably want to call: \"./bin/console set-version ${newVersion}\" afterwards"
74 echo "- You should check if you need to change the composer.json file and the theme.json file for each bundled theme."
75 echo " To change the composer.json file you can call something like: \"composer config extra.branch-alias.dev-master \"5.2.x-dev\"\""
76 echo "- Suggested commit message: Prepare for version ${newVersion}"