Skip to content

GitHub auto release #25

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

Merged
merged 7 commits into from
Dec 9, 2019
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GITHUB_API_TOKEN=
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
/tests/_cache
/var/
/docs.phar
/.env
32 changes: 32 additions & 0 deletions bin/create_release
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env php
<?php

require __DIR__.'/../vendor/autoload.php';

use SymfonyDocsBuilder\Phar\Compiler;
use SymfonyDocsBuilder\Release\Exception\ReleaseFailed;
use SymfonyDocsBuilder\Release\GithubApiHttpClientFactory;
use SymfonyDocsBuilder\Release\Releaser;

error_reporting(-1);
ini_set('display_errors', 1);

try {
$releaser = new Releaser((new GithubApiHttpClientFactory())->createHttpClient(), new Compiler());

if ($argc === 1) {
throw new RuntimeException('Not enough arguments. usage: "./bin/release tag [release_name [release_description]]"');
}

array_shift($argv);

$releaser->createRelease(...$argv);
} catch (Exception $e) {
if ($e instanceof ReleaseFailed) {
echo $e->toString();
} else {
echo 'Failed to create a new release: ['.get_class($e).'] '.$e->getMessage().' at '.$e->getFile().':'.$e->getLine()."\n";
}

exit(1);
}
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@
"symfony/dom-crawler": "^4.1",
"symfony/css-selector": "^4.1",
"symfony/console": "^4.1",
"twig/twig": "^2.7.3"
"twig/twig": "^2.7.3",
"symfony/http-client": "^4.3"
},
"require-dev": {
"gajus/dindent": "^2.0",
"symfony/phpunit-bridge": "^4.1",
"symfony/process": "^4.2"
"symfony/process": "^4.2",
"symfony/dotenv": "^4.3"
}
}
227 changes: 225 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Symfony\Component\Console\Input\InputOption;
use SymfonyDocsBuilder\Command\BuildDocsCommand;
use SymfonyDocsBuilder\Command\CheckUrlsCommand;
use SymfonyDocsBuilder\Command\GithubReleaseCommand;

class Application
{
Expand Down Expand Up @@ -41,6 +42,7 @@ public function run(InputInterface $input): int
);
$this->application->getDefinition()->addOption($inputOption);
$this->application->add(new BuildDocsCommand($this->buildContext));
$this->application->add(new GithubReleaseCommand());

return $this->application->run($input);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Phar/Compiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function compile($pharFile = 'docs.phar')
$finder->files()
->ignoreVCS(true)
->name('*.php')
->notName('Compiler.php')
->exclude(['Release', 'Phar'])
->in(__DIR__.'/..')
;
foreach ($finder as $file) {
Expand Down
29 changes: 29 additions & 0 deletions src/Release/Exception/DeleteReleaseFailed.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php declare(strict_types=1);

namespace SymfonyDocsBuilder\Release\Exception;

use Symfony\Contracts\HttpClient\Exception\HttpExceptionInterface;

class DeleteReleaseFailed extends ReleaseFailed
{
private $originException;

public function __construct(ReleaseFailed $originException, HttpExceptionInterface $previous)
{
$this->originException = $originException;

parent::__construct('Error while deleting release.', 0, $previous);
}

public function toString(): string
{
return sprintf(
"%s\n\nOriginal exception was: [%s]\n\t\"%s\"\n\tat %s:%s\n",
parent::toString(),
get_class($this->originException),
$this->originException->getMessage(),
$this->originException->getFile(),
$this->originException->getLine()
);
}
}
Loading