Translated using Weblate (Slovenian)
[phpmyadmin.git] / scripts / create-release.sh
blob9b984f6b15489f9a626c4fbdbefd0af981952648
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 - in package.json the line
142 " "version": "$version", "
143 - set release date in ChangeLog
145 Continue (y/n)?
147 read do_release
149 if [ "$do_release" != 'y' ]; then
150 exit 100
154 # Create working copy
155 mkdir -p release
156 git worktree prune
157 workdir=release/phpMyAdmin-$version
158 if [ -d $workdir ] ; then
159 echo "Working directory '$workdir' already exists, please move it out of way"
160 exit 1
163 # Add worktree with chosen branch
164 git worktree add --force $workdir $branch
165 cd $workdir
166 if [ $do_pull -eq 1 ] ; then
167 git pull -q
169 if [ $do_daily -eq 1 ] ; then
170 git_head=`git log -n 1 --format=%H`
173 # Check release version
174 if [ $do_ci -eq 0 -a -$do_daily -eq 0 ] ; then
175 if ! grep -q "'PMA_VERSION', '$version'" $CONFIG_LIB ; then
176 echo "There seems to be wrong version in $CONFIG_LIB!"
177 exit 2
179 if ! grep -q "version = '$version'" doc/conf.py ; then
180 echo "There seems to be wrong version in doc/conf.py"
181 exit 2
183 if ! grep -q "Version $version\$" README ; then
184 echo "There seems to be wrong version in README"
185 exit 2
187 if ! grep -q "\"version\": \"$version\"," package.json ; then
188 echo "There seems to be wrong version in package.json"
189 exit 2
193 # Cleanup release dir
194 LC_ALL=C date -u > RELEASE-DATE-${version}
196 # Building documentation
197 echo "* Generating documentation"
198 LC_ALL=C make -C doc html
199 find doc -name '*.pyc' -print0 | xargs -0 -r rm -f
201 # Check for gettext support
202 if [ -d po ] ; then
203 echo "* Generating mo files"
204 ./scripts/generate-mo
205 if [ -f ./scripts/remove-incomplete-mo ] ; then
206 echo "* Removing incomplete translations"
207 ./scripts/remove-incomplete-mo
211 if [ -f ./scripts/line-counts.sh ] ; then
212 echo "* Generating line counts"
213 ./scripts/line-counts.sh
216 echo "* Removing unneeded files"
218 # Remove developer information
219 rm -rf .github
221 # Testsuite setup
222 rm -f .travis.yml .scrutinizer.yml .jshintrc .weblate codecov.yml
224 # Remove readme for github
225 rm -f README.rst
227 if [ ! -d libraries/tcpdf ] ; then
228 case "$branch" in
229 QA_4*) PHP_REQ=$(sed -n '/"php"/ s/.*">=\([0-9]\.[0-9]\).*/\1/p' composer.json) ;;
230 *) PHP_REQ=$(sed -n '/"php"/ s/.*"\^\([0-9]\.[0-9]\.[0-9]\).*/\1/p' composer.json) ;;
231 esac
233 if [ -z "$PHP_REQ" ] ; then
234 echo "Failed to figure out required PHP version from composer.json"
235 exit 2
237 # Okay, there is no way to tell composer to install
238 # suggested package. Let's require it and then revert
239 # composer.json to original state.
240 cp composer.json composer.json.backup
241 echo "* Running composer"
242 composer config platform.php "$PHP_REQ"
243 composer update --no-dev --optimize-autoloader
245 # Parse the required versions from composer.json
246 PACKAGES_VERSIONS=''
247 case "$branch" in
248 QA_4*) PACKAGE_LIST="tecnickcom/tcpdf pragmarx/google2fa bacon/bacon-qr-code samyoul/u2f-php-server" ;;
249 *) PACKAGE_LIST="tecnickcom/tcpdf pragmarx/google2fa-qrcode samyoul/u2f-php-server" ;;
250 esac
252 for PACKAGES in $PACKAGE_LIST
254 PACKAGES_VERSIONS="$PACKAGES_VERSIONS $PACKAGES:`awk "/require-dev/ {printline = 1; print; next } printline" composer.json | grep "$PACKAGES" | awk -F [\\"] '{print $4}'`"
255 done
256 composer require --optimize-autoloader --update-no-dev $PACKAGES_VERSIONS
258 mv composer.json.backup composer.json
259 echo "* Cleanup of composer packages"
260 rm -rf \
261 vendor/phpmyadmin/sql-parser/tests/ \
262 vendor/phpmyadmin/sql-parser/tools/ \
263 vendor/phpmyadmin/sql-parser/locale/*/LC_MESSAGES/sqlparser.po \
264 vendor/phpmyadmin/motranslator/tests/ \
265 vendor/phpmyadmin/shapefile/tests/ \
266 vendor/phpmyadmin/shapefile/examples/ \
267 vendor/phpmyadmin/shapefile/data/ \
268 vendor/phpseclib/phpseclib/phpseclib/File/ \
269 vendor/phpseclib/phpseclib/phpseclib/Math/ \
270 vendor/phpseclib/phpseclib/phpseclib/Net/ \
271 vendor/phpseclib/phpseclib/phpseclib/System/ \
272 vendor/symfony/cache/Tests/ \
273 vendor/symfony/expression-language/Tests/ \
274 vendor/symfony/expression-language/Resources/ \
275 vendor/tecnickcom/tcpdf/examples/ \
276 vendor/tecnickcom/tcpdf/tools/ \
277 vendor/tecnickcom/tcpdf/fonts/ae_fonts_*/ \
278 vendor/tecnickcom/tcpdf/fonts/dejavu-fonts-ttf-2.33/ \
279 vendor/tecnickcom/tcpdf/fonts/freefont-*/ \
280 vendor/tecnickcom/tcpdf/include/sRGB.icc \
281 vendor/twig/extensions/doc \
282 vendor/twig/extensions/test \
283 vendor/twig/twig/doc \
284 vendor/twig/twig/test \
285 vendor/google/recaptcha/examples/ \
286 vendor/google/recaptcha/tests/
287 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
288 find vendor/tecnickcom/tcpdf/fonts/ -maxdepth 1 -type f -not -name 'dejavusans.*' -not -name 'dejavusansb.*' -not -name 'helvetica.php' -print0 | xargs -0 rm
289 if [ $do_tag -eq 1 ] ; then
290 echo "* Commiting composer.lock"
291 git add --force composer.lock
292 git commit -s -m "Adding composer lock for $version"
296 if [ -f package.json ] ; then
297 echo "* Running Yarn"
298 yarn install --production
301 # Remove Bootstrap theme
302 rm -rf themes/bootstrap
304 composer update
305 # Warm up the routing cache
306 ./scripts/console cache:warmup --routing
307 composer update --no-dev --optimize-autoloader
309 # Remove git metadata
310 rm .git
311 find . -name .gitignore -print0 | xargs -0 -r rm -f
312 find . -name .gitattributes -print0 | xargs -0 -r rm -f
314 if [ $do_test -eq 1 ] ; then
315 composer update
316 ./vendor/bin/phpunit --configuration phpunit.xml.nocoverage --exclude-group selenium
317 test_ret=$?
318 if [ $do_ci -eq 1 ] ; then
319 cd ../..
320 rm -rf $workdir
321 git worktree prune
322 if [ "$branch" = "ci" ] ; then
323 git branch -D ci
325 exit $test_ret
327 if [ $test_ret -ne 0 ] ; then
328 exit $test_ret
330 # Remove PHPUnit cache file
331 rm -f .phpunit.result.cache
332 # Remove libs installed for testing
333 rm -rf build
334 composer update --no-dev --optimize-autoloader
338 cd ..
340 # Prepare all kits
341 for kit in $KITS ; do
342 # Copy all files
343 name=phpMyAdmin-$version-$kit
344 cp -r phpMyAdmin-$version $name
346 # Cleanup translations
347 cd phpMyAdmin-$version-$kit
348 ./scripts/lang-cleanup.sh $kit
350 # Remove tests, source code,...
351 if [ $kit != source ] ; then
352 echo "* Removing source files"
353 # Testsuite
354 rm -rf test/
355 rm phpunit.xml.* build.xml
356 rm -f .editorconfig .eslintignore .jshintrc .eslintrc.json .stylelintrc.json psalm.xml psalm-baseline.xml phpstan.neon.dist phpstan-baseline.neon phpcs.xml.dist
357 # Gettext po files
358 rm -rf po/
359 # Documentation source code
360 mv doc/html htmldoc
361 rm -rf doc
362 mkdir doc
363 mv htmldoc doc/html
364 rm doc/html/.buildinfo doc/html/objects.inv
365 # Javascript sources
366 rm -rf js/vendor/openlayers/src/
367 rm -rf node_modules
368 # Remove bin files for non source version
369 # https://github.com/phpmyadmin/phpmyadmin/issues/16033
370 rm -rf vendor/bin
373 # Remove developer scripts
374 rm -rf scripts
376 cd ..
378 # Remove tar file possibly left from previous run
379 rm -f $name.tar
381 # Prepare distributions
382 for comp in $COMPRESSIONS ; do
383 case $comp in
384 tbz|tgz|txz)
385 if [ ! -f $name.tar ] ; then
386 echo "* Creating $name.tar"
387 tar --owner=root --group=root --numeric-owner --sort=name -cf $name.tar $name
389 if [ $comp = txz ] ; then
390 echo "* Creating $name.tar.xz"
391 xz -9k $name.tar
393 if [ $comp = tgz ] ; then
394 echo "* Creating $name.tar.gz"
395 gzip -9c $name.tar > $name.tar.gz
398 zip-7z)
399 echo "* Creating $name.zip"
400 7za a -bd -tzip $name.zip $name > /dev/null
403 echo "WARNING: ignoring compression '$comp', not known!"
405 esac
406 done
409 # Cleanup
410 rm -f $name.tar
411 # Remove directory with current dist set
412 rm -rf $name
413 done
415 # Cleanup
416 rm -rf phpMyAdmin-${version}
417 git worktree prune
419 # Signing of files with default GPG key
420 echo "* Signing files"
421 for file in phpMyAdmin-$version-*.gz phpMyAdmin-$version-*.zip phpMyAdmin-$version-*.xz ; do
422 if [ $do_sign -eq 1 ] ; then
423 gpg --detach-sign --armor $file
425 sha1sum $file > $file.sha1
426 sha256sum $file > $file.sha256
427 done
429 if [ $do_daily -eq 1 ] ; then
430 cat > phpMyAdmin-${version}.json << EOT
432 "date": "`date --iso-8601=seconds`",
433 "commit": "$git_head"
436 exit 0
440 echo ""
441 echo ""
442 echo ""
443 echo "Files:"
444 echo "------"
446 ls -la *.gz *.zip *.xz
448 cd ..
450 # Tag as release
451 if [ $do_tag -eq 1 ] ; then
452 echo
453 echo "Additional tasks:"
454 tagname=RELEASE_`echo $version | tr . _ | tr '[:lower:]' '[:upper:]' | tr -d -`
455 echo "* Tagging release as $tagname"
456 git tag -s -a -m "Released $version" $tagname $branch
457 echo " Dont forget to push tags using: git push --tags"
458 echo "* Cleanup of $branch"
459 # Remove composer.lock, but we need to create fresh worktree for that
460 git worktree add --force $workdir $branch
461 cd $workdir
462 git rm --force composer.lock
463 git commit -s -m "Removing composer.lock"
464 cd ../..
465 rm -rf $workdir
466 git worktree prune
469 # Mark as stable release
470 if [ $do_stable -eq 1 ] ; then
471 mark_as_release $branch STABLE
474 cat <<END
477 Todo now:
478 ---------
480 1. Push the new tag upstream, with a command like git push origin --tags
482 2. Push the new STABLE branch upstream
484 3. prepare a release/phpMyAdmin-$version-notes.html explaining in short the goal of
485 this release and paste into it the ChangeLog for this release, followed
486 by the notes of all previous incremental versions (i.e. 4.4.9 through 4.4.0)
488 4. upload the files to our file server, use scripts/upload-release, eg.:
490 ./scripts/upload-release $version release
492 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/
494 6. send a short mail (with list of major changes) to
495 developers@phpmyadmin.net
496 news@phpmyadmin.net
498 Don't forget to update the Description section in the announcement,
499 based on documentation.
501 7. increment rc count or version in the repository :
502 - in $CONFIG_LIB Config::__constructor() the line
503 " \$this->set( 'PMA_VERSION', '2.7.1-dev' ); "
504 - in Documentation.html (if it exists) the 2 lines
505 " <title>phpMyAdmin 2.2.2-rc1 - Documentation</title> "
506 " <h1>phpMyAdmin 2.2.2-rc1 Documentation</h1> "
507 - in doc/conf.py (if it exists) the line
508 " version = '2.7.1-dev' "
510 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
512 9. for a major release, update demo/php/versions.ini in the scripts repository so that the demo server shows current versions
514 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
516 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