-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
console.php
executable file
·169 lines (158 loc) · 6.28 KB
/
console.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/usr/bin/env php
<?php
declare(strict_types=1);
namespace Laminas\AutomaticReleases\WebApplication;
use ErrorException;
use Http\Discovery\HttpClientDiscovery;
use Http\Discovery\Psr17FactoryDiscovery;
use Laminas\AutomaticReleases\Application\Command\BumpChangelogForReleaseBranch;
use Laminas\AutomaticReleases\Application\Command\CreateMergeUpPullRequest;
use Laminas\AutomaticReleases\Application\Command\CreateMilestones;
use Laminas\AutomaticReleases\Application\Command\ReleaseCommand;
use Laminas\AutomaticReleases\Application\Command\SwitchDefaultBranchToNextMinor;
use Laminas\AutomaticReleases\Changelog\BumpAndCommitChangelogVersionViaKeepAChangelog;
use Laminas\AutomaticReleases\Changelog\ChangelogExistsViaConsole;
use Laminas\AutomaticReleases\Changelog\CommitReleaseChangelogViaKeepAChangelog;
use Laminas\AutomaticReleases\Environment\EnvironmentVariables;
use Laminas\AutomaticReleases\Git\CheckoutBranchViaConsole;
use Laminas\AutomaticReleases\Git\CommitFileViaConsole;
use Laminas\AutomaticReleases\Git\CreateTagViaConsole;
use Laminas\AutomaticReleases\Git\FetchAndSetCurrentUserByReplacingCurrentOriginRemote;
use Laminas\AutomaticReleases\Git\GetMergeTargetCandidateBranchesFromRemoteBranches;
use Laminas\AutomaticReleases\Git\PushViaConsole;
use Laminas\AutomaticReleases\Github\Api\GraphQL\Query\GetMilestoneFirst100IssuesAndPullRequests;
use Laminas\AutomaticReleases\Github\Api\GraphQL\RunGraphQLQuery;
use Laminas\AutomaticReleases\Github\Api\V3\CreateMilestoneThroughApiCall;
use Laminas\AutomaticReleases\Github\Api\V3\CreatePullRequestThroughApiCall;
use Laminas\AutomaticReleases\Github\Api\V3\CreateReleaseThroughApiCall;
use Laminas\AutomaticReleases\Github\Api\V3\SetDefaultBranchThroughApiCall;
use Laminas\AutomaticReleases\Github\CreateReleaseTextThroughChangelog;
use Laminas\AutomaticReleases\Github\CreateReleaseTextViaKeepAChangelog;
use Laminas\AutomaticReleases\Github\Event\Factory\LoadCurrentGithubEventFromGithubActionPath;
use Laminas\AutomaticReleases\Github\JwageGenerateChangelog;
use Laminas\AutomaticReleases\Github\MergeMultipleReleaseNotes;
use Laminas\AutomaticReleases\Gpg\ImportGpgKeyFromStringViaTemporaryFile;
use Lcobucci\Clock\SystemClock;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
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;
use const STDERR;
(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
);
$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);
$getCandidateBranches = new GetMergeTargetCandidateBranchesFromRemoteBranches();
$makeRequests = Psr17FactoryDiscovery::findRequestFactory();
$httpClient = HttpClientDiscovery::find();
$githubToken = $variables->githubToken();
$getMilestone = new GetMilestoneFirst100IssuesAndPullRequests(new RunGraphQLQuery(
$makeRequests,
$httpClient,
$githubToken
));
$changelogExists = new ChangelogExistsViaConsole();
$checkoutBranch = new CheckoutBranchViaConsole();
$commit = new CommitFileViaConsole();
$push = new PushViaConsole();
$commitChangelog = new CommitReleaseChangelogViaKeepAChangelog(
$changelogExists,
$checkoutBranch,
$commit,
$push,
$logger
);
$createCommitText = new CreateReleaseTextThroughChangelog(JwageGenerateChangelog::create(
$makeRequests,
$httpClient
));
$createReleaseText = new MergeMultipleReleaseNotes([
new CreateReleaseTextViaKeepAChangelog($changelogExists, new SystemClock()),
$createCommitText,
]);
$createRelease = new CreateReleaseThroughApiCall(
$makeRequests,
$httpClient,
$githubToken
);
$bumpChangelogVersion = new BumpAndCommitChangelogVersionViaKeepAChangelog(
$changelogExists,
$checkoutBranch,
$commit,
$push,
$logger
);
/** @psalm-suppress DeprecatedClass */
$application = new Application(Versions::ROOT_PACKAGE_NAME, Versions::getVersion('laminas/automatic-releases'));
$application->addCommands([
new ReleaseCommand(
$variables,
$loadEvent,
$fetch,
$getCandidateBranches,
$getMilestone,
$commitChangelog,
$createReleaseText,
new CreateTagViaConsole(),
$push,
$createRelease
),
new CreateMergeUpPullRequest(
$variables,
$loadEvent,
$fetch,
$getCandidateBranches,
$getMilestone,
$createCommitText,
$push,
new CreatePullRequestThroughApiCall(
$makeRequests,
$httpClient,
$githubToken
)
),
new SwitchDefaultBranchToNextMinor(
$variables,
$loadEvent,
$fetch,
$getCandidateBranches,
$push,
new SetDefaultBranchThroughApiCall(
$makeRequests,
$httpClient,
$githubToken
),
$bumpChangelogVersion
),
new BumpChangelogForReleaseBranch(
$variables,
$loadEvent,
$fetch,
$getCandidateBranches,
$bumpChangelogVersion
),
new CreateMilestones(
$loadEvent,
new CreateMilestoneThroughApiCall(
$makeRequests,
$httpClient,
$githubToken,
$logger
)
),
]);
$application->run();
})();