Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Further simplify extension build and release #731

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
@@ -1,3 +1,4 @@
/Libraries/ export-ignore
/Packages/ export-ignore
/Resources/Private/ExtensionArtifacts/ export-ignore
/Resources/Private/Patches/ export-ignore
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
@@ -1,7 +1,7 @@
/.Build/*
/Classes/Console/Hook/*
/Configuration/Console/ComposerPackagesCommands.php
/Libraries/*
/Libraries/vendor
/Resources/Public/*

/.php_cs.cache
Expand Down
11 changes: 5 additions & 6 deletions .travis.yml
Expand Up @@ -94,7 +94,8 @@ jobs:
composer set-version $TRAVIS_TAG
test -z "$(git diff --shortstat 2> /dev/null | tail -n1)";
fi
- composer extension-create-libs && ls -la Libraries/*.phar | grep -v ^-rwx
- composer extension-verify-composer-json
- composer extension-create-libs

- stage: sonar code scanner
if: type = push AND branch IN (master, develop)
Expand All @@ -121,16 +122,14 @@ jobs:
- |
if [ -n "$TYPO3_ORG_USERNAME" ] && [ -n "$TYPO3_ORG_PASSWORD" ]; then
echo -e "Preparing upload of release ${TRAVIS_TAG} to TER\n";
# Install requirements
composer require --dev helhum/ter-client dev-master
# Cleanup before we upload
git reset --hard HEAD && git clean -fx
# Install ter client
composer require --global helhum/ter-client

# Build extension files
composer extension-release

# Upload
TAG_MESSAGE=`git tag -n10 -l $TRAVIS_TAG | sed 's/^[0-9.]*[ ]*//g'`
echo "Uploading release ${TRAVIS_TAG} to TER"
.Build/bin/ter-client upload typo3_console . -u "$TYPO3_ORG_USERNAME" -p "$TYPO3_ORG_PASSWORD" -m "$TAG_MESSAGE"
$HOME/.composer/vendor/bin/ter-client upload typo3_console . -u "$TYPO3_ORG_USERNAME" -p "$TYPO3_ORG_PASSWORD" -m "$TAG_MESSAGE"
fi;
39 changes: 0 additions & 39 deletions Classes/Console/Composer/InstallerScripts.php
Expand Up @@ -15,10 +15,8 @@
*/

use Composer\Script\Event;
use Composer\Script\Event as ScriptEvent;
use Composer\Semver\Constraint\EmptyConstraint;
use Helhum\Typo3Console\Composer\InstallerScript\PopulateCommandConfiguration;
use Symfony\Component\Console\Exception\RuntimeException;
use TYPO3\CMS\Composer\Plugin\Core\InstallerScripts\AutoloadConnector;
use TYPO3\CMS\Composer\Plugin\Core\InstallerScripts\WebDirectory;
use TYPO3\CMS\Composer\Plugin\Core\InstallerScriptsRegistration;
Expand Down Expand Up @@ -49,41 +47,4 @@ public static function register(Event $event, ScriptDispatcher $scriptDispatcher
$scriptDispatcher->addInstallerScript(new AutoloadConnector());
}
}

/**
* @param ScriptEvent $event
* @internal
* @throws RuntimeException
*/
public static function setVersion(ScriptEvent $event)
{
$version = $event->getArguments()[0];
if (!preg_match('/\d+\.\d+\.\d+/', $version)) {
throw new RuntimeException('No valid version number provided!', 1468672604);
}
$docConfigFile = __DIR__ . '/../../../Documentation/Settings.yml';
$content = file_get_contents($docConfigFile);
$content = preg_replace('/(version|release): \d+\.\d+\.\d+/', '$1: ' . $version, $content);
file_put_contents($docConfigFile, $content);

$extEmConfFile = __DIR__ . '/../../../Resources/Private/ExtensionArtifacts/ext_emconf.php';
$content = file_get_contents($extEmConfFile);
$content = preg_replace('/(\'version\' => )\'\d+\.\d+\.\d+/', '$1\'' . $version, $content);
file_put_contents($extEmConfFile, $content);

$applicationFile = __DIR__ . '/../Mvc/Cli/Symfony/Application.php';
$content = file_get_contents($applicationFile);
$content = preg_replace('/(const TYPO3_CONSOLE_VERSION = \')\d+\.\d+\.\d+/', 'const TYPO3_CONSOLE_VERSION = \'' . $version, $content);
file_put_contents($applicationFile, $content);

$travisYmlFile = __DIR__ . '/../../../.travis.yml';
$content = file_get_contents($travisYmlFile);
$content = preg_replace('/(export COMPOSER_ROOT_VERSION)=\d+\.\d+\.\d+/', '$1=' . $version, $content);
file_put_contents($travisYmlFile, $content);

$sonarConfigFile = __DIR__ . '/../../../sonar-project.properties';
$content = file_get_contents($sonarConfigFile);
$content = preg_replace('/(sonar.projectVersion)=\d+\.\d+\.\d+/', '$1=' . $version, $content);
file_put_contents($sonarConfigFile, $content);
}
}
86 changes: 86 additions & 0 deletions Classes/Console/Composer/ScriptHelper.php
@@ -0,0 +1,86 @@
<?php
declare(strict_types=1);
namespace Helhum\Typo3Console\Composer;

/*
* This file is part of the TYPO3 Console project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read
* LICENSE file that was distributed with this source code.
*
*/

use Composer\Script\Event as ScriptEvent;
use Helhum\Typo3Console\Exception;

/**
* Helper for usage in composer.json script section
*/
class ScriptHelper
{
/**
* @param ScriptEvent $event
* @internal
* @throws Exception
*/
public static function setVersion(ScriptEvent $event)
{
$version = $event->getArguments()[0];
if (!preg_match('/\d+\.\d+\.\d+/', $version)) {
throw new Exception('No valid version number provided!', 1468672604);
}
$docConfigFile = __DIR__ . '/../../../Documentation/Settings.yml';
$content = file_get_contents($docConfigFile);
$content = preg_replace('/(version|release): \d+\.\d+\.\d+/', '$1: ' . $version, $content);
file_put_contents($docConfigFile, $content);

$extEmConfFile = __DIR__ . '/../../../Resources/Private/ExtensionArtifacts/ext_emconf.php';
$content = file_get_contents($extEmConfFile);
$content = preg_replace('/(\'version\' => )\'\d+\.\d+\.\d+/', '$1\'' . $version, $content);
file_put_contents($extEmConfFile, $content);

$applicationFile = __DIR__ . '/../Mvc/Cli/Symfony/Application.php';
$content = file_get_contents($applicationFile);
$content = preg_replace('/(const TYPO3_CONSOLE_VERSION = \')\d+\.\d+\.\d+/', 'const TYPO3_CONSOLE_VERSION = \'' . $version, $content);
file_put_contents($applicationFile, $content);

$travisYmlFile = __DIR__ . '/../../../.travis.yml';
$content = file_get_contents($travisYmlFile);
$content = preg_replace('/(export COMPOSER_ROOT_VERSION)=\d+\.\d+\.\d+/', '$1=' . $version, $content);
file_put_contents($travisYmlFile, $content);

$sonarConfigFile = __DIR__ . '/../../../sonar-project.properties';
$content = file_get_contents($sonarConfigFile);
$content = preg_replace('/(sonar.projectVersion)=\d+\.\d+\.\d+/', '$1=' . $version, $content);
file_put_contents($sonarConfigFile, $content);
}

public static function verifyAutoloadInfoInLibraries()
{
$main = json_decode(file_get_contents('composer.json'), true)['autoload'];
$lib = json_decode(file_get_contents('Libraries/composer.json'), true)['autoload'];
if (count($main) !== count($lib)) {
throw new Exception('Count of autoload definition mismatch');
}
if (count($main['psr-4']) !== count($lib['psr-4'])) {
throw new Exception('Count of psr-4 definition mismatch');
}
foreach ($main['psr-4'] as $prefix => $paths) {
if (
count($paths) !== count($lib['psr-4'][$prefix])
|| empty($lib['psr-4'][$prefix])
) {
throw new Exception('Count of psr-4 paths mismatch');
}
foreach ($paths as $index => $path) {
if ('../' . $path !== $lib['psr-4'][$prefix][$index]) {
throw new Exception('Different psr-4 paths defined');
}
}
}
}
}
22 changes: 22 additions & 0 deletions Libraries/composer.json
@@ -0,0 +1,22 @@
{
"config": {
"patform": {
"php": "7.0.8"
},
"classmap-authoritative": true,
"prepend-autoloader": true
},
"autoload": {
"psr-4": {
"Helhum\\Typo3Console\\": [
"../Classes/Console/",
"../Classes/Compatibility/"
]
}
},
"require": {
"symfony/console": "^3.4.4",
"symfony/process": "^3.4.4",
"helhum/config-loader": "^0.9.0"
}
}