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 #174

Closed
wants to merge 53 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
ec1a98b
Add laminas/laminas-twitter
ghostwriter Apr 11, 2021
0925920
Normalize composer.json
ghostwriter Apr 11, 2021
845d5ca
Add support for twitter environment variables
ghostwriter Apr 11, 2021
336a8df
Add Tweet from MilestoneClosedEvent
ghostwriter Apr 11, 2021
2741ed2
Add TweetReleaseCommand
ghostwriter Apr 11, 2021
1fa7f01
Add CreateTweetThroughApiCall
ghostwriter Apr 11, 2021
52f921c
Document and format workflows
ghostwriter Apr 11, 2021
12f550a
Add laminas/laminas-http
ghostwriter Apr 11, 2021
7b8bd31
Update composer.json
ghostwriter Apr 11, 2021
95572f8
Fix wrong URL
ghostwriter Apr 12, 2021
c817856
Fix Psalm errors
ghostwriter Apr 12, 2021
2a7f45c
Refactor `statusesUpdate` returns successful response
ghostwriter Apr 12, 2021
db79703
Fix CS issue
ghostwriter May 23, 2021
198625f
Delete tweet-on-milestone-closed.yml
ghostwriter May 24, 2021
4944c09
Add EnvTrait
ghostwriter May 24, 2021
3c98555
Add VariablesInterface
ghostwriter May 24, 2021
8acd777
Add GithubVariablesInterface
ghostwriter May 24, 2021
90d8404
Add TwitterVariablesInterface
ghostwriter May 24, 2021
5a01283
Add TwitterEnvironmentVariables
ghostwriter May 24, 2021
281735c
Use EnvTrait
ghostwriter May 24, 2021
7401145
Refactor Twitter EnvironmentVariables
ghostwriter May 24, 2021
c2393af
Update EnvironmentVariablesTest
ghostwriter May 24, 2021
d99d65b
Add GithubEnvironmentVariables
ghostwriter May 24, 2021
33283cf
Refactor environment variables
ghostwriter May 24, 2021
7485a5f
Refactor loading current Github action event
ghostwriter May 24, 2021
c776e70
Move TweetReleaseCommand to tweet-on-release
ghostwriter May 24, 2021
e271c00
Define vendor binaries
ghostwriter May 24, 2021
7da0042
Update example workflow
ghostwriter May 24, 2021
a369d5b
Add example workflow with a custom tweet (not supported, yet)
ghostwriter May 24, 2021
d8bec47
Update composer.lock
ghostwriter May 24, 2021
37d2601
Add scripts section
ghostwriter Dec 18, 2021
7c6f8c8
Remove unnecessary files
ghostwriter Dec 18, 2021
f81376f
Update example workflows
ghostwriter Dec 18, 2021
e59087e
Add GitHub CLI to the Docker container
ghostwriter Dec 18, 2021
f9fe899
Suppress MissingConstructor in `./test`
ghostwriter Dec 18, 2021
3f06fce
Delete TweetReleaseCommand.php
ghostwriter Dec 18, 2021
978cf3b
Simplify EnvironmentVariables
ghostwriter Dec 18, 2021
a8d9c60
Update test and fix imports
ghostwriter Dec 18, 2021
be2f96c
Implement announcements and fix imports
ghostwriter Dec 18, 2021
f49a91d
Update action.yml
ghostwriter Dec 18, 2021
45b5dd2
Update composer.json
ghostwriter Dec 18, 2021
82c3f4d
Update composer.lock
ghostwriter Dec 18, 2021
e56f0d1
clean up
ghostwriter Dec 18, 2021
38f8f29
Update .laminas-ci.json
ghostwriter Dec 19, 2021
6cd45ed
Add psalm-baseline.xml
ghostwriter Dec 19, 2021
34725c7
Refactor call
ghostwriter Dec 19, 2021
f10da19
Delete tweet-on-release.yml
ghostwriter Dec 19, 2021
9027ffd
Update examples
ghostwriter Dec 19, 2021
94843a5
Update automatic-release.yml
ghostwriter Dec 19, 2021
e699d0b
Clean up tests
ghostwriter Dec 19, 2021
bab39c5
Update psalm-baseline.xml
ghostwriter Dec 19, 2021
018d43d
Fix phpcs
ghostwriter Dec 19, 2021
f538501
Update PublishTweetTest.php
ghostwriter Dec 19, 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
5 changes: 5 additions & 0 deletions .github/workflows/automatic-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ jobs:
"SIGNING_SECRET_KEY": ${{ secrets.SIGNING_SECRET_KEY }}
"GIT_AUTHOR_NAME": ${{ secrets.GIT_AUTHOR_NAME }}
"GIT_AUTHOR_EMAIL": ${{ secrets.GIT_AUTHOR_EMAIL }}
# If any of the Twitter Environment Variables are missing, it is disabled by default.
"TWITTER_CONSUMER_API_KEY": ${{ secrets.TWITTER_CONSUMER_API_KEY }}
"TWITTER_CONSUMER_API_SECRET": ${{ secrets.TWITTER_CONSUMER_API_SECRET }}
"TWITTER_ACCESS_TOKEN": ${{ secrets.TWITTER_ACCESS_TOKEN }}
"TWITTER_ACCESS_TOKEN_SECRET": ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}

- name: "Create Merge-Up Pull Request"
uses: "./.github/actions/automatic-releases/"
Expand Down
3 changes: 2 additions & 1 deletion .laminas-ci.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"extensions": [
"bcmath"
]
],
"stablePHP": "8.0"
}
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ RUN apk add --no-cache git gnupg libzip icu-dev \
&& docker-php-ext-install intl \
&& apk del .build-deps

ENV GH_VERSION=2.0.0
## GITHUB CLI
RUN wget --no-check-certificate https://github.com/cli/cli/releases/download/v${GH_VERSION}/gh_${GH_VERSION}_linux_amd64.tar.gz \
&& tar -zxvf gh_${GH_VERSION}_linux_amd64.tar.gz \
&& mv gh_${GH_VERSION}_linux_amd64/bin/gh /usr/local/bin/gh \
&& chmod +x /usr/local/bin/gh \
&& gh --version

COPY composer.* /app/

RUN COMPOSER_CACHE_DIR=/dev/null composer install --no-dev --no-autoloader
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
45 changes: 31 additions & 14 deletions bin/console.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

namespace Laminas\AutomaticReleases\WebApplication;

use Abraham\TwitterOAuth\TwitterOAuth;
use ChangelogGenerator\GitHubOAuthToken;
use DateTimeZone;
use ErrorException;
Expand Down Expand Up @@ -37,6 +38,7 @@
use Laminas\AutomaticReleases\Github\JwageGenerateChangelog;
use Laminas\AutomaticReleases\Github\MergeMultipleReleaseNotes;
use Laminas\AutomaticReleases\Gpg\ImportGpgKeyFromStringViaTemporaryFile;
use Laminas\AutomaticReleases\Twitter\PublishTweet;
use Lcobucci\Clock\SystemClock;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
Expand All @@ -51,6 +53,7 @@
use const STDERR;

(static function (): void {
/** @psalm-suppress MissingFile */
require_once __DIR__ . '/../vendor/autoload.php';

set_error_handler(
Expand All @@ -60,15 +63,18 @@ static function (int $errorCode, string $message = '', string $file = '', int $l
E_STRICT | E_NOTICE | E_WARNING
);

$variables = EnvironmentVariables::fromEnvironment(new ImportGpgKeyFromStringViaTemporaryFile());
$logger = new Logger('automatic-releases');
$logger->pushHandler(new StreamHandler(STDERR, $variables->logLevel()));
$loadEvent = new LoadCurrentGithubEventFromGithubActionPath($variables);
$fetch = new FetchAndSetCurrentUserByReplacingCurrentOriginRemote($variables);
$environment = EnvironmentVariables::fromEnvironmentWithGpgKey(
new ImportGpgKeyFromStringViaTemporaryFile()
);
$logger = (new Logger('automatic-releases'))->pushHandler(
new StreamHandler(STDERR, $environment->logLevel())
);
$loadEvent = new LoadCurrentGithubEventFromGithubActionPath($environment);
$fetch = new FetchAndSetCurrentUserByReplacingCurrentOriginRemote($environment);
$getCandidateBranches = new GetMergeTargetCandidateBranchesFromRemoteBranches();
$makeRequests = Psr17FactoryDiscovery::findRequestFactory();
$httpClient = HttpClientDiscovery::find();
$githubToken = $variables->githubToken();
$githubToken = $environment->githubToken();
$getMilestone = new GetMilestoneFirst100IssuesAndPullRequests(new RunGraphQLQuery(
$makeRequests,
$httpClient,
Expand All @@ -91,14 +97,18 @@ static function (int $errorCode, string $message = '', string $file = '', int $l
new GitHubOAuthToken($githubToken)
));
$createReleaseText = new MergeMultipleReleaseNotes([
new CreateReleaseTextViaKeepAChangelog($changelogExists, new SystemClock(new DateTimeZone('UTC'))),
new CreateReleaseTextViaKeepAChangelog(
$changelogExists,
new SystemClock(new DateTimeZone('UTC'))
),
$createCommitText,
]);
$createRelease = new CreateReleaseThroughApiCall(
$makeRequests,
$httpClient,
$githubToken
);

$bumpChangelogVersion = new BumpAndCommitChangelogVersionViaKeepAChangelog(
$changelogExists,
$checkoutBranch,
Expand All @@ -107,12 +117,10 @@ static function (int $errorCode, string $message = '', string $file = '', int $l
$logger
);

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

$application->addCommands([
new ReleaseCommand(
$variables,
$environment,
$loadEvent,
$fetch,
$getCandidateBranches,
Expand All @@ -121,10 +129,19 @@ static function (int $errorCode, string $message = '', string $file = '', int $l
$createReleaseText,
new CreateTagViaConsole(),
$push,
$createRelease
$createRelease,
new PublishTweet(
new TwitterOAuth(
$environment->twitterConsumerApiKey(),
$environment->twitterConsumerApiSecret(),
$environment->twitterAccessToken(),
$environment->twitterAccessTokenSecret()
),
$environment
)
),
new CreateMergeUpPullRequest(
$variables,
$environment,
$loadEvent,
$fetch,
$getCandidateBranches,
Expand All @@ -138,7 +155,7 @@ static function (int $errorCode, string $message = '', string $file = '', int $l
)
),
new SwitchDefaultBranchToNextMinor(
$variables,
$environment,
$loadEvent,
$fetch,
$getCandidateBranches,
Expand All @@ -151,7 +168,7 @@ static function (int $errorCode, string $message = '', string $file = '', int $l
$bumpChangelogVersion
),
new BumpChangelogForReleaseBranch(
$variables,
$environment,
$loadEvent,
$fetch,
$getCandidateBranches,
Expand Down
54 changes: 37 additions & 17 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,51 @@
"description": "Application that eases release management in the Laminas organisation through GitHub actions",
"license": "BSD-3-Clause",
"require": {
"php": "^8.0.0",
"azjezz/psl": "^1.8.1",
"jwage/changelog-generator": "^1.3.0",
"laminas/laminas-diactoros": "^2.5.0",
"lcobucci/clock": "^2.0.0",
"monolog/monolog": "^2.2.0",
"ocramius/package-versions": "^2.3.0",
"php": "^8.0.0,<8.2",
"abraham/twitteroauth": "^3.2.0",
"azjezz/psl": "^1.9.3",
"jwage/changelog-generator": "^1.3.1",
"laminas/laminas-diactoros": "^2.8.0",
"laminas/laminas-http": "^2.15.1",
"lcobucci/clock": "^2.1.0",
"monolog/monolog": "^2.3.5",
"ocramius/package-versions": "^2.4.0",
"phly/keep-a-changelog": "^2.11.0",
"php-http/curl-client": "^2.2.0",
"php-http/discovery": "^1.14.0",
"php-http/curl-client": "^2.2.1",
"php-http/discovery": "^1.14.1",
"php-http/httplug": "^2.2.0",
"psr/http-client": "^1.0.1",
"psr/http-message": "^1.0.1",
"psr/log": "^1.1.3",
"symfony/console": "^5.2.3"
"psr/log": "^1.1.4",
"symfony/console": "^5.4.1",
"symfony/process": "^5.4.0"
},
"require-dev": {
"doctrine/coding-standard": "^9.0.0",
"php-standard-library/psalm-plugin": "^1.1.1",
"phpunit/phpunit": "^9.5.0",
"psalm/plugin-phpunit": "^0.15.1",
"roave/infection-static-analysis-plugin": "^1.7",
"squizlabs/php_codesniffer": "^3.5.8",
"vimeo/psalm": "^4.7.2"
"phpunit/phpunit": "^9.5.10",
"psalm/plugin-phpunit": "^0.16.1",
"roave/infection-static-analysis-plugin": "^1.13.0",
"roave/security-advisories": "dev-latest",
"vimeo/psalm": "^4.15.0"
},
"config": {
"sort-packages": true
},

"scripts": {
"check": [
"@cs-check",
"@test",
"@psalm",
"@infection"
],
"cs-check": "phpcs",
"cs-fix": "phpcbf",
"infection": "vendor/bin/roave-infection-static-analysis-plugin",
"static-analysis": "psalm --shepherd --stats",
"test": "vendor/bin/phpunit --stop-on-failure --colors=always"
},
"autoload": {
"psr-4": {
"Laminas\\AutomaticReleases\\": "src"
Expand All @@ -41,5 +58,8 @@
"psr-4": {
"Laminas\\AutomaticReleases\\Test\\Unit\\": "test/unit"
}
}
},
"bin": [
"bin/console.php"
]
}
Loading