Use non-breaking space entity instead of newline in the links on the browse page.
[phpmyadmin.git] / scripts / create-release.sh
blob86d5d91df72fb84419c7e2d01e798e7b5462ed7f
1 #!/bin/sh
3 # vim: expandtab sw=4 ts=4 sts=4:
6 # Do not run as CGI
7 if [ -n "$GATEWAY_INTERFACE" ] ; then
8 echo 'Can not invoke as CGI!'
9 exit 1
12 # More documentation about making a release is available at:
13 # https://wiki.phpmyadmin.net/pma/Releasing
15 # Fail on undefined variables
16 set -u
17 # Fail on failure
18 set -e
20 KITS="all-languages english source"
21 COMPRESSIONS="zip-7z txz tgz"
23 # Process parameters
25 version=""
26 branch=""
27 do_tag=0
28 do_stable=0
29 do_test=0
30 do_ci=0
32 while [ $# -gt 0 ] ; do
33 case "$1" in
34 --tag)
35 do_tag=1
37 --stable)
38 do_stable=1
40 --test)
41 do_test=1
43 --ci)
44 do_test=1
45 do_ci=1
46 if [ -z "$branch" ] ; then
47 git branch ci
48 branch="ci"
50 version="ci"
52 --help)
53 echo "Usages:"
54 echo " create-release.sh <version> <from_branch> [--tag] [--stable] [--test] [--ci]"
55 echo ""
56 echo "If --tag is specified, release tag is automatically created (use this for all releases including pre-releases)"
57 echo "If --stable is specified, the STABLE branch is updated with this release"
58 echo "If --test is specified, the testsuite is executed before creating the release"
59 echo "If --ci is specified, the testsuite is executed and no actual release is crated"
60 echo ""
61 echo "Examples:"
62 echo " create-release.sh 2.9.0-rc1 QA_2_9"
63 echo " create-release.sh 2.9.0 MAINT_2_9_0 --tag --stable"
64 exit 65
67 if [ -z "$version" ] ; then
68 version=`echo $1 | tr -d -c '0-9a-z.-'`
69 if [ "x$version" != "x$1" ] ; then
70 echo "Invalid version: $1"
71 exit 1
73 elif [ -z "$branch" ] ; then
74 branch=`echo $1 | tr -d -c '0-9A-Za-z_-'`
75 if [ "x$branch" != "x$1" ] ; then
76 echo "Invalid branch: $1"
77 exit 1
79 else
80 echo "Unknown parameter: $1!"
81 exit 1
83 esac
84 shift
85 done
87 if [ -z "$version" -o -z "$branch" ] ; then
88 echo "Branch and version have to be specified!"
89 exit 1
92 # Checks whether remote branch has local tracking branch
93 ensure_local_branch() {
94 if ! git branch | grep -q '^..'"$1"'$' ; then
95 git branch --track $1 origin/$1
99 # Marks current head of given branch as head of other branch
100 # Used for STABLE tracking
101 mark_as_release() {
102 branch=$1
103 rel_branch=$2
104 echo "* Marking release as $rel_branch"
105 ensure_local_branch $rel_branch
106 git checkout $rel_branch
107 git merge -s recursive -X theirs $branch
108 git checkout master
111 # Ensure we have tracking branch
112 ensure_local_branch $branch
114 # Check if we're releasing older
115 if git cat-file -e $branch:libraries/Config.php 2> /dev/null ; then
116 CONFIG_LIB=libraries/Config.php
117 else
118 CONFIG_LIB=libraries/Config.class.php
121 if [ $do_ci -eq 0 ] ; then
122 cat <<END
124 Please ensure you have incremented rc count or version in the repository :
125 - in $CONFIG_LIB PMA\libraries\Config::__constructor() the line
126 " \$this->set( 'PMA_VERSION', '$version' ); "
127 - in doc/conf.py the line
128 " version = '$version' "
129 - in README
130 - set release date in ChangeLog
132 Continue (y/n)?
134 read do_release
136 if [ "$do_release" != 'y' ]; then
137 exit 100
141 # Create working copy
142 mkdir -p release
143 git worktree prune
144 workdir=release/phpMyAdmin-$version
145 if [ -d $workdir ] ; then
146 echo "Working directory '$workdir' already exists, please move it out of way"
147 exit 1
150 # Add worktree with chosen branch
151 git worktree add --force $workdir $branch
152 cd $workdir
154 # Check release version
155 if [ $do_ci -eq 0 ] ; then
156 if ! grep -q "'PMA_VERSION', '$version'" $CONFIG_LIB ; then
157 echo "There seems to be wrong version in $CONFIG_LIB!"
158 exit 2
160 if ! grep -q "version = '$version'" doc/conf.py ; then
161 echo "There seems to be wrong version in doc/conf.py"
162 exit 2
164 if ! grep -q "Version $version\$" README ; then
165 echo "There seems to be wrong version in README"
166 exit 2
170 # Cleanup release dir
171 LC_ALL=C date -u > RELEASE-DATE-${version}
173 # Building documentation
174 echo "* Generating documentation"
175 LC_ALL=C make -C doc html
176 find doc -name '*.pyc' -print0 | xargs -0 -r rm -f
178 # Check for gettext support
179 if [ -d po ] ; then
180 echo "* Generating mo files"
181 ./scripts/generate-mo
182 if [ -f ./scripts/remove-incomplete-mo ] ; then
183 echo "* Removing incomplete translations"
184 ./scripts/remove-incomplete-mo
188 if [ -f ./scripts/line-counts.sh ] ; then
189 echo "* Generating line counts"
190 ./scripts/line-counts.sh
193 echo "* Removing unneeded files"
195 # Remove developer information
196 rm -rf .github
198 # Remove phpcs coding standard definition
199 rm -rf PMAStandard
201 # Testsuite setup
202 rm -f .travis.yml .coveralls.yml .scrutinizer.yml .jshintrc .weblate codecov.yml
204 # Remove readme for github
205 rm -f README.rst
207 if [ ! -d libraries/tcpdf ] ; then
208 echo "* Running composer"
209 composer update --no-dev
210 # Okay, there is no way to tell composer to install
211 # suggested package. Let's require it and then revert
212 # composer.json to original state.
213 cp composer.json composer.json.backup
214 composer require --update-no-dev tecnickcom/tcpdf
215 mv composer.json.backup composer.json
216 echo "* Cleanup of composer packages"
217 rm -rf \
218 vendor/phpmyadmin/sql-parser/tests/ \
219 vendor/phpmyadmin/sql-parser/tools/ \
220 vendor/phpmyadmin/sql-parser/locale/*/LC_MESSAGES/sqlparser.po \
221 vendor/phpmyadmin/motranslator/tests/ \
222 vendor/phpmyadmin/shapefile/tests/ \
223 vendor/phpmyadmin/shapefile/examples/ \
224 vendor/phpmyadmin/shapefile/data/ \
225 vendor/phpseclib/phpseclib/phpseclib/File/ \
226 vendor/phpseclib/phpseclib/phpseclib/Math/ \
227 vendor/phpseclib/phpseclib/phpseclib/Net/ \
228 vendor/phpseclib/phpseclib/phpseclib/System/ \
229 vendor/symfony/expression-language/Tests/ \
230 vendor/symfony/expression-language/Resources/ \
231 vendor/tecnickcom/tcpdf/examples/ \
232 vendor/tecnickcom/tcpdf/tools/ \
233 vendor/tecnickcom/tcpdf/fonts/ae_fonts_*/ \
234 vendor/tecnickcom/tcpdf/fonts/dejavu-fonts-ttf-2.33/ \
235 vendor/tecnickcom/tcpdf/fonts/freefont-*/ \
236 vendor/tecnickcom/tcpdf/include/sRGB.icc \
237 vendor/google/recaptcha/examples/ \
238 vendor/google/recaptcha/tests/
239 find vendor/phpseclib/phpseclib/phpseclib/Crypt/ -maxdepth 1 -type f -not -name AES.php -not -name Base.php -not -name Random.php -not -name Rijndael.php -print0 | xargs -0 rm
240 find vendor/tecnickcom/tcpdf/fonts/ -maxdepth 1 -type f -not -name 'dejavusans.*' -not -name 'dejavusansb.*' -not -name 'helvetica.php' -print0 | xargs -0 rm
241 if [ $do_tag -eq 1 ] ; then
242 echo "* Commiting composer.lock"
243 sed -i '/composer.lock/D' .gitignore
244 git add .gitignore
245 git add composer.lock
246 git commit -s -m "Adding composer lock for $version"
250 # Remove git metadata
251 rm .git
252 find . -name .gitignore -print0 | xargs -0 -r rm -f
254 if [ $do_test -eq 1 ] ; then
255 composer update
256 ant phpunit-nocoverage
257 test_ret=$?
258 if [ $do_ci -eq 1 ] ; then
259 cd ../..
260 rm -rf $workdir
261 git worktree prune
262 if [ "$branch" = "ci" ] ; then
263 git branch -D ci
265 exit $test_ret
267 if [ $test_ret -ne 0 ] ; then
268 exit $test_ret
270 # Remove libs installed for testing
271 if [ ! -d libraries/tcpdf ] ; then
272 composer update --no-dev
277 cd ..
279 # Prepare all kits
280 for kit in $KITS ; do
281 # Copy all files
282 name=phpMyAdmin-$version-$kit
283 cp -r phpMyAdmin-$version $name
285 # Cleanup translations
286 cd phpMyAdmin-$version-$kit
287 ./scripts/lang-cleanup.sh $kit
289 # Remove tests, source code,...
290 if [ $kit != source ] ; then
291 echo "* Removing source files"
292 # Testsuite
293 rm -rf test/
294 rm phpunit.xml.* build.xml
295 # Gettext po files
296 rm -rf po/
297 # Documentation source code
298 mv doc/html htmldoc
299 rm -rf doc
300 mkdir doc
301 mv htmldoc doc/html
302 rm doc/html/.buildinfo doc/html/objects.inv
303 # Javascript sources
304 rm -rf js/jquery/src/ js/openlayers/src/
307 # Remove developer scripts
308 rm -rf scripts
310 cd ..
312 # Remove tar file possibly left from previous run
313 rm -f $name.tar
315 # Prepare distributions
316 for comp in $COMPRESSIONS ; do
317 case $comp in
318 tbz|tgz|txz)
319 if [ ! -f $name.tar ] ; then
320 echo "* Creating $name.tar"
321 tar --owner=root --group=root --numeric-owner --sort=name -cf $name.tar $name
323 if [ $comp = txz ] ; then
324 echo "* Creating $name.tar.xz"
325 xz -9k $name.tar
327 if [ $comp = tgz ] ; then
328 echo "* Creating $name.tar.gz"
329 gzip -9c $name.tar > $name.tar.gz
332 zip-7z)
333 echo "* Creating $name.zip"
334 7za a -bd -tzip $name.zip $name > /dev/null
337 echo "WARNING: ignoring compression '$comp', not known!"
339 esac
340 done
343 # Cleanup
344 rm -f $name.tar
345 # Remove directory with current dist set
346 rm -rf $name
347 done
349 # Cleanup
350 rm -rf phpMyAdmin-${version}
351 git worktree prune
353 # Signing of files with default GPG key
354 echo "* Signing files"
355 for file in *.gz *.zip *.xz ; do
356 gpg --detach-sign --armor $file
357 sha1sum $file > $file.sha1
358 sha256sum $file > $file.sha256
359 done
362 echo ""
363 echo ""
364 echo ""
365 echo "Files:"
366 echo "------"
368 ls -la *.gz *.zip *.xz
370 cd ..
372 # Tag as release
373 if [ $do_tag -eq 1 ] ; then
374 echo
375 echo "Additional tasks:"
376 tagname=RELEASE_`echo $version | tr . _ | tr '[:lower:]' '[:upper:]' | tr -d -`
377 echo "* Tagging release as $tagname"
378 git tag -s -a -m "Released $version" $tagname $branch
379 echo " Dont forget to push tags using: git push --tags"
382 # Mark as stable release
383 if [ $do_stable -eq 1 ] ; then
384 mark_as_release $branch STABLE
387 cat <<END
390 Todo now:
391 ---------
393 1. If not already done, tag the repository with the new revision number
394 for a plain release or a release candidate:
395 version 2.7.0 gets RELEASE_2_7_0
396 version 2.7.1-rc1 gets RELEASE_2_7_1RC1
398 2. prepare a release/phpMyAdmin-$version-notes.html explaining in short the goal of
399 this release and paste into it the ChangeLog for this release, followed
400 by the notes of all previous incremental versions (i.e. 4.4.9 through 4.4.0)
401 3. upload the files to our file server, use scripts/upload-release, eg.:
403 ./scripts/upload-release $version release
404 4. add a news item to our website; a good idea is to include a link to the release notes such as https://www.phpmyadmin.net/files/4.4.10/
405 5. send a short mail (with list of major changes) to
406 developers@phpmyadmin.net
407 news@phpmyadmin.net
409 Don't forget to update the Description section in the announcement,
410 based on documentation.
412 6. increment rc count or version in the repository :
413 - in $CONFIG_LIB PMA\libraries\Config::__constructor() the line
414 " \$this->set( 'PMA_VERSION', '2.7.1-dev' ); "
415 - in Documentation.html (if it exists) the 2 lines
416 " <title>phpMyAdmin 2.2.2-rc1 - Documentation</title> "
417 " <h1>phpMyAdmin 2.2.2-rc1 Documentation</h1> "
418 - in doc/conf.py (if it exists) the line
419 " version = '2.7.1-dev' "
421 7. on https://github.com/phpmyadmin/phpmyadmin/milestones close the milestone corresponding to the released version (if this is a stable release) and open a new one for the next minor release
423 8. for a stable version, update demo/php/versions.ini in the scripts repository so that the demo server shows current versions
425 9. in case of a new major release ('y' in x.y.0), update the pmaweb/settings.py in website repository to include the new major releases
427 10. the end :-)