Create github release

[MAILPOET-2004]
This commit is contained in:
Pavel Dohnal
2019-05-23 12:50:10 +02:00
committed by M. Shull
parent ca175c81fb
commit b47484ee3c
2 changed files with 42 additions and 0 deletions

View File

@@ -14,6 +14,8 @@ class GitHubController {
const RELEASE_SOURCE_BRANCH = 'release';
const QA_GITHUB_LOGIN = 'michelleshull';
/** @var string */
private $zip_filename;
@@ -32,6 +34,31 @@ class GitHubController {
]);
}
public function createReleasePullRequest($version) {
$response = $this->http_client->post('pulls', [
'json' => [
'title' => 'Release ' . $version,
'head' => self::RELEASE_SOURCE_BRANCH,
'base' => 'master',
],
]);
$response = json_decode($response->getBody()->getContents(), true);
$pull_request_number = $response['number'];
if (!$pull_request_number) {
throw new \Exception('Failed to create a new release pull request');
}
$this->assignPullRequest($pull_request_number);
}
private function assignPullRequest($pull_request_number) {
$this->http_client->post("pulls/$pull_request_number/requested_reviewers", [
'json' => ['reviewers' => [self::QA_GITHUB_LOGIN]],
]);
$this->http_client->post("issues/$pull_request_number/assignees", [
'json' => ['assignees' => [self::QA_GITHUB_LOGIN]],
]);
}
public function publishRelease($version, $changelog, $release_zip_path) {
$this->ensureNoDraftReleaseExists();
$this->ensureReleaseDoesNotExistYet($version);