diff --git a/.craft.yml b/.craft.yml index df763ddc..eacd7244 100644 --- a/.craft.yml +++ b/.craft.yml @@ -2,7 +2,6 @@ minVersion: 0.23.1 changelogPolicy: simple artifactProvider: name: none -preReleaseCommand: '' targets: - name: github - name: registry diff --git a/CHANGELOG.md b/CHANGELOG.md index f261e210..55e98384 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Add support for tracing of the Symfony HTTP client requests (#606) - Support logging the impersonator user, if any (#647) +- ref: Use constant for the SDK version (#662) ## 4.3.1 (2022-10-10) diff --git a/scripts/bump-version.sh b/scripts/bump-version.sh new file mode 100755 index 00000000..edd3a204 --- /dev/null +++ b/scripts/bump-version.sh @@ -0,0 +1,24 @@ +#!/bin/bash +set -eux + +# if [ "$(uname -s)" != "Linux" ]; then +# echo "Please use the GitHub Action." +# exit 1 +# fi + +SCRIPT_DIR="$( dirname "$0" )" +cd $SCRIPT_DIR/.. + +OLD_VERSION="${1}" +NEW_VERSION="${2}" + +echo "Current version: $OLD_VERSION" +echo "Bumping version: $NEW_VERSION" + +function replace() { + ! grep "$2" $3 + perl -i -pe "s/$1/$2/g" $3 + grep "$2" $3 # verify that replacement was successful +} + +replace "SDK_VERSION = '[0-9.]+'" "SDK_VERSION = '$NEW_VERSION'" ./src/SentryBundle.php diff --git a/src/DependencyInjection/SentryExtension.php b/src/DependencyInjection/SentryExtension.php index e60e7a84..110b855b 100644 --- a/src/DependencyInjection/SentryExtension.php +++ b/src/DependencyInjection/SentryExtension.php @@ -5,7 +5,6 @@ namespace Sentry\SentryBundle\DependencyInjection; use Doctrine\Bundle\DoctrineBundle\DoctrineBundle; -use Jean85\PrettyVersions; use LogicException; use Psr\Log\NullLogger; use Sentry\Client; @@ -140,7 +139,7 @@ private function registerConfiguration(ContainerBuilder $container, array $confi $clientBuilderDefinition = (new Definition(ClientBuilder::class)) ->setArgument(0, new Reference('sentry.client.options')) ->addMethodCall('setSdkIdentifier', [SentryBundle::SDK_IDENTIFIER]) - ->addMethodCall('setSdkVersion', [PrettyVersions::getVersion('sentry/sentry-symfony')->getPrettyVersion()]) + ->addMethodCall('setSdkVersion', [SentryBundle::SDK_VERSION]) ->addMethodCall('setTransportFactory', [new Reference($config['transport_factory'])]) ->addMethodCall('setSerializer', [$serializer]) ->addMethodCall('setRepresentationSerializer', [$representationSerializerDefinition]) diff --git a/src/SentryBundle.php b/src/SentryBundle.php index 130999eb..51804144 100644 --- a/src/SentryBundle.php +++ b/src/SentryBundle.php @@ -14,6 +14,8 @@ final class SentryBundle extends Bundle { public const SDK_IDENTIFIER = 'sentry.php.symfony'; + public const SDK_VERSION = '4.3.1'; + public function build(ContainerBuilder $container): void { parent::build($container); diff --git a/src/Transport/TransportFactory.php b/src/Transport/TransportFactory.php index 4a74dce0..6ddd272b 100644 --- a/src/Transport/TransportFactory.php +++ b/src/Transport/TransportFactory.php @@ -6,7 +6,6 @@ use Http\Client\HttpAsyncClient as HttpAsyncClientInterface; use Http\Discovery\Psr17FactoryDiscovery; -use Jean85\PrettyVersions; use Psr\Http\Message\RequestFactoryInterface; use Psr\Http\Message\ResponseFactoryInterface; use Psr\Http\Message\StreamFactoryInterface; @@ -14,6 +13,7 @@ use Psr\Log\LoggerInterface; use Sentry\HttpClient\HttpClientFactory; use Sentry\Options; +use Sentry\SentryBundle\SentryBundle; use Sentry\Transport\DefaultTransportFactory; use Sentry\Transport\TransportFactoryInterface; use Sentry\Transport\TransportInterface; @@ -52,7 +52,7 @@ public function __construct( $streamFactory, $httpClient, 'sentry.php.symfony', - PrettyVersions::getVersion('sentry/sentry-symfony')->getPrettyVersion() + SentryBundle::SDK_VERSION ), $logger ); diff --git a/tests/DependencyInjection/SentryExtensionTest.php b/tests/DependencyInjection/SentryExtensionTest.php index e907e512..30a17193 100644 --- a/tests/DependencyInjection/SentryExtensionTest.php +++ b/tests/DependencyInjection/SentryExtensionTest.php @@ -5,7 +5,6 @@ namespace Sentry\SentryBundle\Tests\DependencyInjection; use Doctrine\Bundle\DoctrineBundle\DoctrineBundle; -use Jean85\PrettyVersions; use PHPUnit\Framework\TestCase; use Psr\Log\NullLogger; use Sentry\ClientInterface; @@ -244,7 +243,7 @@ public function testClientIsCreatedFromOptions(): void $this->assertCount(6, $methodCalls); $this->assertDefinitionMethodCallAt($methodCalls[0], 'setSdkIdentifier', [SentryBundle::SDK_IDENTIFIER]); - $this->assertDefinitionMethodCallAt($methodCalls[1], 'setSdkVersion', [PrettyVersions::getVersion('sentry/sentry-symfony')->getPrettyVersion()]); + $this->assertDefinitionMethodCallAt($methodCalls[1], 'setSdkVersion', [SentryBundle::SDK_VERSION]); $this->assertDefinitionMethodCallAt($methodCalls[2], 'setTransportFactory', [new Reference('App\\Sentry\\Transport\\TransportFactory')]); $this->assertDefinitionMethodCallAt($methodCalls[5], 'setLogger', [new Reference('app.logger')]);