Translated using Weblate (German)
[phpmyadmin.git] / scripts / create-release.sh
blob6ef8e09c1a382da9a0e8a93303eb7758c468fa22
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
31 do_sign=1
32 do_pull=0
33 do_daily=0
35 while [ $# -gt 0 ] ; do
36 case "$1" in
37 --tag)
38 do_tag=1
40 --stable)
41 do_stable=1
43 --test)
44 do_test=1
46 --daily)
47 do_sign=0
48 do_pull=1
49 do_daily=1
50 do_test=1
52 --ci)
53 do_test=1
54 do_ci=1
55 if [ -z "$branch" ] ; then
56 git branch ci
57 branch="ci"
59 version="ci"
61 --help)
62 echo "Usages:"
63 echo " create-release.sh <version> <from_branch> [--tag] [--stable] [--test] [--ci]"
64 echo ""
65 echo "If --tag is specified, release tag is automatically created (use this for all releases including pre-releases)"
66 echo "If --stable is specified, the STABLE branch is updated with this release"
67 echo "If --test is specified, the testsuite is executed before creating the release"
68 echo "If --ci is specified, the testsuite is executed and no actual release is created"
69 echo ""
70 echo "Examples:"
71 echo " create-release.sh 2.9.0-rc1 QA_2_9"
72 echo " create-release.sh 2.9.0 MAINT_2_9_0 --tag --stable"
73 exit 65
76 if [ -z "$version" ] ; then
77 version=`echo $1 | tr -d -c '0-9a-z.+-'`
78 if [ "x$version" != "x$1" ] ; then
79 echo "Invalid version: $1"
80 exit 1
82 elif [ -z "$branch" ] ; then
83 branch=`echo $1 | tr -d -c '0-9A-Za-z_-'`
84 if [ "x$branch" != "x$1" ] ; then
85 echo "Invalid branch: $1"
86 exit 1
88 else
89 echo "Unknown parameter: $1!"
90 exit 1
92 esac
93 shift
94 done
96 if [ -z "$version" -o -z "$branch" ] ; then
97 echo "Branch and version have to be specified!"
98 exit 1
101 # Checks whether remote branch has local tracking branch
102 ensure_local_branch() {
103 if ! git branch | grep -q '^..'"$1"'$' ; then
104 git branch --track $1 origin/$1
108 # Marks current head of given branch as head of other branch
109 # Used for STABLE tracking
110 mark_as_release() {
111 branch=$1
112 rel_branch=$2
113 echo "* Marking release as $rel_branch"
114 ensure_local_branch $rel_branch
115 git checkout $rel_branch
116 git merge -s recursive -X theirs $branch
117 git checkout master
120 # Ensure we have tracking branch
121 ensure_local_branch $branch
123 # Check if we're releasing older
124 if git cat-file -e $branch:libraries/classes/Config.php 2> /dev/null ; then
125 CONFIG_LIB=libraries/classes/Config.php
126 elif git cat-file -e $branch:libraries/Config.php 2> /dev/null ; then
127 CONFIG_LIB=libraries/Config.php
128 else
129 CONFIG_LIB=libraries/Config.class.php
132 if [ $do_ci -eq 0 -a -$do_daily -eq 0 ] ; then
133 cat <<END
135 Please ensure you have incremented rc count or version in the repository :
136 - in $CONFIG_LIB Config::__constructor() the line
137 " \$this->set( 'PMA_VERSION', '$version' ); "
138 - in doc/conf.py the line
139 " version = '$version' "
140 - in README
141 - set release date in ChangeLog
143 Continue (y/n)?
145 read do_release
147 if [ "$do_release" != 'y' ]; then
148 exit 100
152 # Create working copy
153 mkdir -p release
154 git worktree prune
155 workdir=release/phpMyAdmin-$version
156 if [ -d $workdir ] ; then
157 echo "Working directory '$workdir' already exists, please move it out of way"
158 exit 1
161 # Add worktree with chosen branch
162 git worktree add --force $workdir $branch
163 cd $workdir
164 if [ $do_pull -eq 1 ] ; then
165 git pull -q
167 if [ $do_daily -eq 1 ] ; then
168 git_head=`git log -n 1 --format=%H`
171 # Check release version
172 if [ $do_ci -eq 0 -a -$do_daily -eq 0 ] ; then
173 if ! grep -q "'PMA_VERSION', '$version'" $CONFIG_LIB ; then
174 echo "There seems to be wrong version in $CONFIG_LIB!"
175 exit 2
177 if ! grep -q "version = '$version'" doc/conf.py ; then
178 echo "There seems to be wrong version in doc/conf.py"
179 exit 2
181 if ! grep -q "Version $version\$" README ; then
182 echo "There seems to be wrong version in README"
183 exit 2
187 # Cleanup release dir
188 LC_ALL=C date -u > RELEASE-DATE-${version}
190 # Building documentation
191 echo "* Generating documentation"
192 LC_ALL=C make -C doc html
193 find doc -name '*.pyc' -print0 | xargs -0 -r rm -f
195 # Check for gettext support
196 if [ -d po ] ; then
197 echo "* Generating mo files"
198 ./scripts/generate-mo
199 if [ -f ./scripts/remove-incomplete-mo ] ; then
200 echo "* Removing incomplete translations"
201 ./scripts/remove-incomplete-mo
205 if [ -f ./scripts/line-counts.sh ] ; then
206 echo "* Generating line counts"
207 ./scripts/line-counts.sh
210 echo "* Removing unneeded files"
212 # Remove developer information
213 rm -rf .github
215 # Remove phpcs coding standard definition
216 rm -rf PMAStandard
218 # Testsuite setup
219 rm -f .travis.yml .coveralls.yml .scrutinizer.yml .jshintrc .weblate codecov.yml
221 # Remove readme for github
222 rm -f README.rst
224 if [ ! -d libraries/tcpdf ] ; then
225 if [ "$branch" = "QA_4_8" ] ; then
226 PHP_REQ=`sed -n '/"php"/ s/.*">=\([0-9]\.[0-9]\).*/\1/p' composer.json`
227 else
228 PHP_REQ=`sed -n '/"php"/ s/.*"\^\([0-9]\.[0-9]\.[0-9]\).*/\1/p' composer.json`
231 if [ -z "$PHP_REQ" ] ; then
232 echo "Failed to figure out required PHP version from composer.json"
233 exit 2
235 # Okay, there is no way to tell composer to install
236 # suggested package. Let's require it and then revert
237 # composer.json to original state.
238 cp composer.json composer.json.backup
239 echo "* Running composer"
240 composer config platform.php "$PHP_REQ"
241 composer update --no-dev
243 # Parse the required versions from composer.json
244 PACKAGES_VERSIONS=''
245 if [ "$branch" = "QA_4_8" ] ; then
246 PACKAGE_LIST="tecnickcom/tcpdf pragmarx/google2fa bacon/bacon-qr-code samyoul/u2f-php-server"
247 else
248 PACKAGE_LIST="tecnickcom/tcpdf pragmarx/google2fa-qrcode samyoul/u2f-php-server"
250 for PACKAGES in $PACKAGE_LIST
252 PACKAGES_VERSIONS="$PACKAGES_VERSIONS $PACKAGES:`awk "/require-dev/ {printline = 1; print; next } printline" composer.json | grep "$PACKAGES" | awk -F [\\"] '{print $4}'`"
253 done
254 composer require --update-no-dev $PACKAGES_VERSIONS
256 mv composer.json.backup composer.json
257 echo "* Cleanup of composer packages"
258 rm -rf \
259 vendor/phpmyadmin/sql-parser/tests/ \
260 vendor/phpmyadmin/sql-parser/tools/ \
261 vendor/phpmyadmin/sql-parser/locale/*/LC_MESSAGES/sqlparser.po \
262 vendor/phpmyadmin/motranslator/tests/ \
263 vendor/phpmyadmin/shapefile/tests/ \
264 vendor/phpmyadmin/shapefile/examples/ \
265 vendor/phpmyadmin/shapefile/data/ \
266 vendor/phpseclib/phpseclib/phpseclib/File/ \
267 vendor/phpseclib/phpseclib/phpseclib/Math/ \
268 vendor/phpseclib/phpseclib/phpseclib/Net/ \
269 vendor/phpseclib/phpseclib/phpseclib/System/ \
270 vendor/symfony/cache/Tests/ \
271 vendor/symfony/expression-language/Tests/ \
272 vendor/symfony/expression-language/Resources/ \
273 vendor/tecnickcom/tcpdf/examples/ \
274 vendor/tecnickcom/tcpdf/tools/ \
275 vendor/tecnickcom/tcpdf/fonts/ae_fonts_*/ \
276 vendor/tecnickcom/tcpdf/fonts/dejavu-fonts-ttf-2.33/ \
277 vendor/tecnickcom/tcpdf/fonts/freefont-*/ \
278 vendor/tecnickcom/tcpdf/include/sRGB.icc \
279 vendor/twig/extensions/doc \
280 vendor/twig/extensions/test \
281 vendor/twig/twig/doc \
282 vendor/twig/twig/test \
283 vendor/google/recaptcha/examples/ \
284 vendor/google/recaptcha/tests/
285 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
286 find vendor/tecnickcom/tcpdf/fonts/ -maxdepth 1 -type f -not -name 'dejavusans.*' -not -name 'dejavusansb.*' -not -name 'helvetica.php' -print0 | xargs -0 rm
287 if [ $do_tag -eq 1 ] ; then
288 echo "* Commiting composer.lock"
289 git add --force composer.lock
290 git commit -s -m "Adding composer lock for $version"
294 if [ -f package.json ] ; then
295 echo "* Running Yarn"
296 yarn install --production
299 # Remove git metadata
300 rm .git
301 find . -name .gitignore -print0 | xargs -0 -r rm -f
302 find . -name .gitattributes -print0 | xargs -0 -r rm -f
304 if [ $do_test -eq 1 ] ; then
305 composer update
306 ./vendor/bin/phpunit --configuration phpunit.xml.nocoverage --exclude-group selenium
307 test_ret=$?
308 if [ $do_ci -eq 1 ] ; then
309 cd ../..
310 rm -rf $workdir
311 git worktree prune
312 if [ "$branch" = "ci" ] ; then
313 git branch -D ci
315 exit $test_ret
317 if [ $test_ret -ne 0 ] ; then
318 exit $test_ret
320 # Remove libs installed for testing
321 rm -rf build
322 composer update --no-dev
326 cd ..
328 # Prepare all kits
329 for kit in $KITS ; do
330 # Copy all files
331 name=phpMyAdmin-$version-$kit
332 cp -r phpMyAdmin-$version $name
334 # Cleanup translations
335 cd phpMyAdmin-$version-$kit
336 ./scripts/lang-cleanup.sh $kit
338 # Remove tests, source code,...
339 if [ $kit != source ] ; then
340 echo "* Removing source files"
341 # Testsuite
342 rm -rf test/
343 rm phpunit.xml.* build.xml
344 # Gettext po files
345 rm -rf po/
346 # Documentation source code
347 mv doc/html htmldoc
348 rm -rf doc
349 mkdir doc
350 mv htmldoc doc/html
351 rm doc/html/.buildinfo doc/html/objects.inv
352 # Javascript sources
353 rm -rf js/vendor/openlayers/src/
354 rm -rf node_modules
357 # Remove developer scripts
358 rm -rf scripts
360 cd ..
362 # Remove tar file possibly left from previous run
363 rm -f $name.tar
365 # Prepare distributions
366 for comp in $COMPRESSIONS ; do
367 case $comp in
368 tbz|tgz|txz)
369 if [ ! -f $name.tar ] ; then
370 echo "* Creating $name.tar"
371 tar --owner=root --group=root --numeric-owner --sort=name -cf $name.tar $name
373 if [ $comp = txz ] ; then
374 echo "* Creating $name.tar.xz"
375 xz -9k $name.tar
377 if [ $comp = tgz ] ; then
378 echo "* Creating $name.tar.gz"
379 gzip -9c $name.tar > $name.tar.gz
382 zip-7z)
383 echo "* Creating $name.zip"
384 7za a -bd -tzip $name.zip $name > /dev/null
387 echo "WARNING: ignoring compression '$comp', not known!"
389 esac
390 done
393 # Cleanup
394 rm -f $name.tar
395 # Remove directory with current dist set
396 rm -rf $name
397 done
399 # Cleanup
400 rm -rf phpMyAdmin-${version}
401 git worktree prune
403 # Signing of files with default GPG key
404 echo "* Signing files"
405 for file in phpMyAdmin-$version-*.gz phpMyAdmin-$version-*.zip phpMyAdmin-$version-*.xz ; do
406 if [ $do_sign -eq 1 ] ; then
407 gpg --detach-sign --armor $file
409 sha1sum $file > $file.sha1
410 sha256sum $file > $file.sha256
411 done
413 if [ $do_daily -eq 1 ] ; then
414 cat > phpMyAdmin-${version}.json << EOT
416 "date": "`date --iso-8601=seconds`",
417 "commit": "$git_head"
420 exit 0
424 echo ""
425 echo ""
426 echo ""
427 echo "Files:"
428 echo "------"
430 ls -la *.gz *.zip *.xz
432 cd ..
434 # Tag as release
435 if [ $do_tag -eq 1 ] ; then
436 echo
437 echo "Additional tasks:"
438 tagname=RELEASE_`echo $version | tr . _ | tr '[:lower:]' '[:upper:]' | tr -d -`
439 echo "* Tagging release as $tagname"
440 git tag -s -a -m "Released $version" $tagname $branch
441 echo " Dont forget to push tags using: git push --tags"
442 echo "* Cleanup of $branch"
443 # Remove composer.lock, but we need to create fresh worktree for that
444 git worktree add --force $workdir $branch
445 cd $workdir
446 git rm --force composer.lock
447 git commit -s -m "Removing composer.lock"
448 cd ../..
449 rm -rf $workdir
450 git worktree prune
453 # Mark as stable release
454 if [ $do_stable -eq 1 ] ; then
455 mark_as_release $branch STABLE
458 cat <<END
461 Todo now:
462 ---------
464 1. Push the new tag upstream, with a command like git push origin --tags
466 2. Push the new STABLE branch upstream
468 3. prepare a release/phpMyAdmin-$version-notes.html explaining in short the goal of
469 this release and paste into it the ChangeLog for this release, followed
470 by the notes of all previous incremental versions (i.e. 4.4.9 through 4.4.0)
472 4. upload the files to our file server, use scripts/upload-release, eg.:
474 ./scripts/upload-release $version release
476 5. 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/
478 6. send a short mail (with list of major changes) to
479 developers@phpmyadmin.net
480 news@phpmyadmin.net
482 Don't forget to update the Description section in the announcement,
483 based on documentation.
485 7. increment rc count or version in the repository :
486 - in $CONFIG_LIB Config::__constructor() the line
487 " \$this->set( 'PMA_VERSION', '2.7.1-dev' ); "
488 - in Documentation.html (if it exists) the 2 lines
489 " <title>phpMyAdmin 2.2.2-rc1 - Documentation</title> "
490 " <h1>phpMyAdmin 2.2.2-rc1 Documentation</h1> "
491 - in doc/conf.py (if it exists) the line
492 " version = '2.7.1-dev' "
494 8. 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
496 9. for a major release, update demo/php/versions.ini in the scripts repository so that the demo server shows current versions
498 10. 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
500 11. update the Dockerfile in the docker repository to reflect the new version and create a new annotated tag (such as with git tag -s -a 4.7.9-1 -m "Version 4.7.9-1"). Remember to push the tag with git push origin --tags