Skip to content

Commit ea46247

Browse files
committed
Use flat php file to create release instead of a symfony command
1 parent 8293e7a commit ea46247

File tree

7 files changed

+251
-224
lines changed

7 files changed

+251
-224
lines changed

bin/create_release

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
require __DIR__.'/../vendor/autoload.php';
5+
6+
use SymfonyDocsBuilder\Release\GithubApiHttpClientFactory;
7+
use SymfonyDocsBuilder\Release\Releaser;
8+
9+
error_reporting(-1);
10+
ini_set('display_errors', 1);
11+
12+
try {
13+
$releaser = new Releaser(new GithubApiHttpClientFactory());
14+
15+
if ($argc === 1) {
16+
throw new RuntimeException('Not enough arguments. usage: "./bin/release tag [release_name [release_description]]"');
17+
}
18+
19+
array_shift($argv);
20+
21+
$releaser->doRelease(...$argv);
22+
} catch (Exception $e) {
23+
echo 'Failed to create a new release: ['.get_class($e).'] '.$e->getMessage().' at '.$e->getFile().':'.$e->getLine()."\n";
24+
exit(1);
25+
}

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020
"symfony/css-selector": "^4.1",
2121
"symfony/console": "^4.1",
2222
"twig/twig": "^2.7.3",
23-
"symfony/http-client": "^4.3",
24-
"symfony/dotenv": "^4.3"
23+
"symfony/http-client": "^4.3"
2524
},
2625
"require-dev": {
2726
"gajus/dindent": "^2.0",
2827
"symfony/phpunit-bridge": "^4.1",
29-
"symfony/process": "^4.2"
28+
"symfony/process": "^4.2",
29+
"symfony/dotenv": "^4.3"
3030
}
3131
}

composer.lock

Lines changed: 58 additions & 58 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Command/GithubReleaseCommand.php

Lines changed: 0 additions & 162 deletions
This file was deleted.

src/Phar/Compiler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function compile($pharFile = 'docs.phar')
5959
$finder->files()
6060
->ignoreVCS(true)
6161
->name('*.php')
62-
->notName('Compiler.php')
62+
->exclude(['Release', 'Phar'])
6363
->in(__DIR__.'/..')
6464
;
6565
foreach ($finder as $file) {
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace SymfonyDocsBuilder\Release;
4+
5+
use Symfony\Component\Dotenv\Dotenv;
6+
use Symfony\Component\HttpClient\HttpClient;
7+
use Symfony\Contracts\HttpClient\HttpClientInterface;
8+
9+
class GithubApiHttpClientFactory
10+
{
11+
private $githubApiToken;
12+
13+
public function __construct()
14+
{
15+
$dotenv = new Dotenv();
16+
$dotenv->load(__DIR__.'/../../.env');
17+
18+
if (empty($_SERVER['GITHUB_API_TOKEN'])) {
19+
throw new \RuntimeException('Please fill "GITHUB_API_TOKEN" in file "[PROJECT_DIR]/.env"');
20+
}
21+
22+
$this->githubApiToken = $_SERVER['GITHUB_API_TOKEN'];
23+
}
24+
25+
public function createHttpClient(): HttpClientInterface
26+
{
27+
$client = HttpClient::create(
28+
[
29+
'headers' => [
30+
'Authorization' => sprintf('token %s', $this->githubApiToken),
31+
],
32+
]
33+
);
34+
35+
return $client;
36+
}
37+
}

0 commit comments

Comments
 (0)