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

GitHub auto release #25

merged 7 commits into from
Dec 9, 2019

Conversation

nikophil
Copy link
Collaborator

No description provided.

@nikophil nikophil requested a review from weaverryan September 18, 2019 19:09
$dotenv = new Dotenv();
$dotenv->load(__DIR__.'/../../.env');

if (empty($_ENV['GITHUB_API_TOKEN'])) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some edge-case reason, I'm told we should use $_SERVER for env vars :)

use Symfony\Component\Process\Process;
use Symfony\Contracts\HttpClient\HttpClientInterface;

class GithubReleaseCommand extends Command
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having a command to release a command-line library feels weird to me - there's no reason, for example, that this should even been accessible when you're working with the phar file. Could we make this a flat bin/create_release file? We would still require the autoloader... and then probably we could refactor some of the code into "service classes" that are used in that script (so that the script is ultimately tiny). We could then not include this script nor those supporting classes in the phar file.

$this->client = $this->createHttpClient($_ENV['GITHUB_API_TOKEN']);

$tag = $input->getArgument('tag');
if (!preg_match('/^v\d+\.\d+\.\d+$/', $tag)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for a sanity check!

$message = 'Maybe the tag name already exists?';
}

throw new RuntimeException(sprintf('Error while trying to create release: %s.', $message), 0, $exception);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

'target_commitish' => 'master',
'name' => $this->name,
'description' => $this->description,
'draft' => false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. Could we set this draft => true, then upload the asset, then modify it to draft=>false? That's minor... but it would eliminate any time when the release is published and has no phar attached.

composer.json Outdated
"twig/twig": "^2.7.3"
"twig/twig": "^2.7.3",
"symfony/http-client": "^4.3",
"symfony/dotenv": "^4.3"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move to require-dev

@weaverryan weaverryan merged commit fd75ae5 into master Dec 9, 2019
@weaverryan weaverryan deleted the github-auto-release branch December 9, 2019 03:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants