Skip to content
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

Feature: Twitter release announcement #129

Closed
wants to merge 31 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
eee6544
Add laminas/laminas-twitter
ghostwriter Apr 11, 2021
399de0e
Normalize composer.json
ghostwriter Apr 11, 2021
0fc01bb
Add support for twitter environment variables
ghostwriter Apr 11, 2021
f8bf716
Add Tweet from MilestoneClosedEvent
ghostwriter Apr 11, 2021
4741c10
Add TweetReleaseCommand
ghostwriter Apr 11, 2021
3abff1f
Add CreateTweetThroughApiCall
ghostwriter Apr 11, 2021
1e9b792
Document and format workflows
ghostwriter Apr 11, 2021
17f5784
Add laminas/laminas-http
ghostwriter Apr 11, 2021
89d1923
Update composer.json
ghostwriter Apr 11, 2021
9819620
Fix wrong URL
ghostwriter Apr 12, 2021
45024bf
Fix Psalm errors
ghostwriter Apr 12, 2021
fd1317d
Refactor `statusesUpdate` returns successful response
ghostwriter Apr 12, 2021
450ab8c
Fix CS issue
ghostwriter May 23, 2021
a89fe6a
Delete tweet-on-milestone-closed.yml
ghostwriter May 24, 2021
3749554
Add EnvTrait
ghostwriter May 24, 2021
6476601
Add VariablesInterface
ghostwriter May 24, 2021
91e42e4
Add GithubVariablesInterface
ghostwriter May 24, 2021
15daddd
Add TwitterVariablesInterface
ghostwriter May 24, 2021
42b9492
Add TwitterEnvironmentVariables
ghostwriter May 24, 2021
aba8f4f
Use EnvTrait
ghostwriter May 24, 2021
0193c98
Refactor Twitter EnvironmentVariables
ghostwriter May 24, 2021
9018408
Update EnvironmentVariablesTest
ghostwriter May 24, 2021
daf1725
Add GithubEnvironmentVariables
ghostwriter May 24, 2021
d11b4e1
Refactor environment variables
ghostwriter May 24, 2021
d47e50e
Refactor loading current Github action event
ghostwriter May 24, 2021
7bc2d2f
Move TweetReleaseCommand to tweet-on-release
ghostwriter May 24, 2021
d236eab
Define vendor binaries
ghostwriter May 24, 2021
ecac1cb
Update example workflow
ghostwriter May 24, 2021
52c879c
Add example workflow with a custom tweet (not supported, yet)
ghostwriter May 24, 2021
319a174
Update composer.lock
ghostwriter May 24, 2021
5a10262
Fix CS issues
ghostwriter May 24, 2021
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 .github/actions/automatic-releases/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ inputs:
description: |
Command to execute: one of
* `laminas:automatic-releases:release`
* `laminas:automatic-releases:tweet-release`
* `laminas:automatic-releases:create-merge-up-pull-request`
* `laminas:automatic-releases:switch-default-branch-to-next-minor`
required: true
Expand Down
1 change: 1 addition & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ inputs:
description: |
Command to execute: one of
* `laminas:automatic-releases:release`
* `laminas:automatic-releases:tweet-release`
* `laminas:automatic-releases:create-merge-up-pull-request`
* `laminas:automatic-releases:switch-default-branch-to-next-minor`
required: true
Expand Down
4 changes: 2 additions & 2 deletions bin/console.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ static function (int $errorCode, string $message = '', string $file = '', int $l
E_STRICT | E_NOTICE | E_WARNING
);

$variables = EnvironmentVariables::fromEnvironment(new ImportGpgKeyFromStringViaTemporaryFile());
$variables = EnvironmentVariables::fromEnvironmentWithGpgKey(new ImportGpgKeyFromStringViaTemporaryFile());
$loadEvent = new LoadCurrentGithubEventFromGithubActionPath($variables);
$logger = new Logger('automatic-releases');
$logger->pushHandler(new StreamHandler(STDERR, $variables->logLevel()));
$loadEvent = new LoadCurrentGithubEventFromGithubActionPath($variables);
$fetch = new FetchAndSetCurrentUserByReplacingCurrentOriginRemote($variables);
$getCandidateBranches = new GetMergeTargetCandidateBranchesFromRemoteBranches();
$makeRequests = Psr17FactoryDiscovery::findRequestFactory();
Expand Down
60 changes: 60 additions & 0 deletions bin/tweet-on-release.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/env php
<?php

declare(strict_types=1);

namespace Laminas\AutomaticReleases;

use ErrorException;
use Laminas\AutomaticReleases\Application\Command\TweetReleaseCommand;
use Laminas\AutomaticReleases\Environment\GithubEnvironmentVariables;
use Laminas\AutomaticReleases\Environment\TwitterEnvironmentVariables;
use Laminas\AutomaticReleases\Github\Event\Factory\LoadCurrentGithubEventFromGithubActionPath;
use Laminas\AutomaticReleases\Twitter\CreateTweetThroughApiCall;
use Laminas\Twitter\Twitter;
use PackageVersions\Versions;
use Symfony\Component\Console\Application;

use function set_error_handler;

use const E_NOTICE;
use const E_STRICT;
use const E_WARNING;

(static function (): void {
require_once __DIR__ . '/../vendor/autoload.php';

set_error_handler(
static function (int $errorCode, string $message = '', string $file = '', int $line = 0): bool {
throw new ErrorException($message, 0, $errorCode, $file, $line);
},
E_STRICT | E_NOTICE | E_WARNING
);

$twitterEnvironmentVariables = TwitterEnvironmentVariables::fromEnvironment();
$githubEnvironmentVariables = GithubEnvironmentVariables::fromEnvironment();
$loadEvent = new LoadCurrentGithubEventFromGithubActionPath($githubEnvironmentVariables);

// /** @psalm-suppress DeprecatedClass */
$application = new Application(Versions::rootPackageName(), Versions::getVersion('laminas/automatic-releases'));

$application->addCommands([
new TweetReleaseCommand(
$loadEvent,
new CreateTweetThroughApiCall(
new Twitter([
'access_token' => [
'token' => $twitterEnvironmentVariables->accessToken(),
'secret' => $twitterEnvironmentVariables->accessTokenSecret(),
],
'oauth_options' => [
'consumerKey' => $twitterEnvironmentVariables->consumerApiKey(),
'consumerSecret' => $twitterEnvironmentVariables->consumerApiSecret(),
],
])
)
),
]);

$application->run();
})();
13 changes: 11 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"azjezz/psl": "^1.7.1",
"jwage/changelog-generator": "^1.3.0",
"laminas/laminas-diactoros": "^2.5.0",
"laminas/laminas-http": "^2.14",
"laminas/laminas-twitter": "^3.1",
"lcobucci/clock": "^2.0.0",
"monolog/monolog": "^2.2.0",
"ocramius/package-versions": "^2.3.0",
Expand All @@ -18,7 +20,10 @@
"psr/http-client": "^1.0.1",
"psr/http-message": "^1.0.1",
"psr/log": "^1.1.3",
"symfony/console": "^5.2.3"
"symfony/console": "^5.2.3",
"symfony/process": "^5.2.3",
"thecodingmachine/safe": "^1.3.3",
"webmozart/assert": "^1.9.1"
},
"require-dev": {
"doctrine/coding-standard": "^9.0.0",
Expand All @@ -41,5 +46,9 @@
"psr-4": {
"Laminas\\AutomaticReleases\\Test\\Unit\\": "test/unit"
}
}
},
"bin": [
"bin/console.php",
"bin/tweet-on-release.php"
]
}
Loading