Skip to content

Commit

Permalink
Improve the release script for versionning
Browse files Browse the repository at this point in the history
Signed-off-by: William Desportes <williamdes@wdes.fr>

Improve the version handling

Signed-off-by: William Desportes <williamdes@wdes.fr>

Simplify the version handling

Signed-off-by: William Desportes <williamdes@wdes.fr>
  • Loading branch information
williamdes committed Feb 21, 2021
1 parent f3cf7d7 commit f28fbe0
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 25 deletions.
9 changes: 3 additions & 6 deletions libraries/classes/Config.php
Expand Up @@ -136,12 +136,9 @@ public function __construct(?string $source = null)
*/
public function checkSystem(): void
{
$this->set('PMA_VERSION', '5.1.0-rc2');
/* Major version */
$this->set(
'PMA_MAJOR_VERSION',
implode('.', array_slice(explode('.', $this->get('PMA_VERSION'), 3), 0, 2))
);
// All the version handling is now done in the Version class
$this->set('PMA_VERSION', Version::phpMyAdminVersion());
$this->set('PMA_MAJOR_VERSION', Version::phpMyAdminSeriesVersion());

$this->checkWebServerOs();
$this->checkWebServer();
Expand Down
67 changes: 67 additions & 0 deletions libraries/classes/Version.php
@@ -0,0 +1,67 @@
<?php

declare(strict_types=1);

namespace PhpMyAdmin;

use function defined;

/**
* Class to handle the phpMyAdmin version
*/
final class Version
{
/*
* Packaging people can add a version suffix using the VERSION_SUFFIX constant at vendor_config.php
*/

public const VERSION_MAJOR = 5;
public const VERSION_MINOR = 1;
public const VERSION_PATCH = 0;

// The version will be {major}.{minor}.{patch}-dev
public const IS_DEV = true;

// The version will be {major}.{minor}.{patch}-{PRE_RELEASE_NAME} if not empty
public const PRE_RELEASE_NAME = '';

/**
* Get the current phpMyAdmin series version
*
* @example 5.1
*/
public static function phpMyAdminSeriesVersion(): string
{
return self::VERSION_MAJOR . '.' . self::VERSION_MINOR;
}

/**
* Get the current phpMyAdmin version
*/
public static function phpMyAdminVersion(): string
{
$versionRaw = self::VERSION_MAJOR . '.' . self::VERSION_MINOR . '.' . self::VERSION_PATCH;

if (self::IS_DEV) {
return $versionRaw . '-dev';
}

if (self::PRE_RELEASE_NAME !== '') {
return $versionRaw . '-' . self::PRE_RELEASE_NAME;
}

if (defined('VERSION_SUFFIX')) {
return $versionRaw . VERSION_SUFFIX;
}

return $versionRaw;
}

/**
* If the current version is a dev version
*/
public static function isDev(): bool
{
return self::IS_DEV;
}
}
5 changes: 5 additions & 0 deletions libraries/vendor_config.php
Expand Up @@ -79,3 +79,8 @@
* Define the cache directory for routing cache an other cache files
*/
define('CACHE_DIR', ROOT_PATH . 'libraries' . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR);

/**
* Suffix to add to the phpMyAdmin version
*/
define('VERSION_SUFFIX', '');
2 changes: 2 additions & 0 deletions phpstan.neon.dist
Expand Up @@ -20,3 +20,5 @@ parameters:
- tmp/*
- twig-templates/*
- vendor/*
dynamicConstantNames:
- VERSION_SUFFIX
54 changes: 35 additions & 19 deletions scripts/create-release.sh
Expand Up @@ -238,24 +238,29 @@ delete_phpunit_sandbox() {
# Ensure we have tracking branch
ensure_local_branch $branch

# Check if we're releasing older
if git cat-file -e $branch:libraries/classes/Config.php 2> /dev/null ; then
CONFIG_LIB=libraries/classes/Config.php
elif git cat-file -e $branch:libraries/Config.php 2> /dev/null ; then
CONFIG_LIB=libraries/Config.php
else
CONFIG_LIB=libraries/Config.class.php
fi
VERSION_FILE=libraries/classes/Version.php

fetchReleaseFromFile() {
php -r "require_once('libraries/classes/Version.php'); echo \PhpMyAdmin\Version::phpMyAdminVersion();"
}

echo "The actual configured release is: $(fetchReleaseFromFile)"

if [ $do_ci -eq 0 -a -$do_daily -eq 0 ] ; then
cat <<END
Please ensure you have incremented rc count or version in the repository :
- in $CONFIG_LIB Config::__constructor() the line
" \$this->set('PMA_VERSION', '$version'); "
- in $VERSION_FILE Version class:
- check that VERSION_MAJOR, VERSION_MINOR and VERSION_PATCH are correct.
- for a normal release
- check that IS_DEV is false
- check that PRE_RELEASE_NAME is empty
- for a -rc release
- check that IS_DEV is false
- change PRE_RELEASE_NAME to "rc1"
- in doc/conf.py the line
" version = '$version' "
- in README
- in README the "Version" line
- in package.json the line
" "version": "$version", "
- set release date in ChangeLog
Expand All @@ -269,6 +274,8 @@ END
fi
fi

echo "The actual configured release is now: $(fetchReleaseFromFile)"

# Create working copy
mkdir -p release
git worktree prune
Expand All @@ -290,8 +297,8 @@ fi

# Check release version
if [ $do_ci -eq 0 -a -$do_daily -eq 0 ] ; then
if ! grep -q "'PMA_VERSION', '$version'" $CONFIG_LIB ; then
echo "There seems to be wrong version in $CONFIG_LIB!"
if ! grep -q "'PMA_VERSION', '$version'" $VERSION_FILE ; then
echo "There seems to be wrong version in $VERSION_FILE!"
exit 2
fi
if ! grep -q "version = '$version'" doc/conf.py ; then
Expand Down Expand Up @@ -601,11 +608,20 @@ Todo now:
based on documentation.
7. increment rc count or version in the repository :
- in $CONFIG_LIB Config::__constructor() the line
" \$this->set( 'PMA_VERSION', '2.7.1-dev' ); "
- in Documentation.html (if it exists) the 2 lines
" <title>phpMyAdmin 2.2.2-rc1 - Documentation</title> "
" <h1>phpMyAdmin 2.2.2-rc1 Documentation</h1> "
- in $VERSION_FILE Version class:
- for a dev cycle
- set IS_DEV to true
- check that PRE_RELEASE_NAME is empty
- for a normal release
- check that IS_DEV is false
- check that PRE_RELEASE_NAME is empty
- for a -rc release
- check that IS_DEV is false
- change PRE_RELEASE_NAME to "rc1"
- in README the "Version" line
" Version 2.7.1-dev "
- in package.json the line
" "version": " 2.7.1-dev", "
- in doc/conf.py (if it exists) the line
" version = '2.7.1-dev' "
Expand All @@ -615,6 +631,6 @@ Todo now:
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
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
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 {tagName}
END

0 comments on commit f28fbe0

Please sign in to comment.