-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathmake-release.php
More file actions
398 lines (314 loc) · 9.74 KB
/
make-release.php
File metadata and controls
398 lines (314 loc) · 9.74 KB
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
<?php
if ($argc <= 1) {
die("Usage: {$argv[0]} <version> <<'from_master'>>");
}
$xdebugRepo = '/home/derick/dev/php/xdebug-xdebug';
$xdebugOrgRepo = '/home/derick/dev/php/xdebug-xdebug.org';
$url = "https://bugs.xdebug.org/api/rest/";
$project_id = 1;
$release_version = $argv[1];
$from_master = false;
if ( $argc == 3 ) {
$from_master = ( $argv[2] == 'from_master' );
}
$stability = 'stable';
if ( preg_match( '/beta|alpha|RC|rc/', $release_version ) )
{
$stability = 'beta';
}
echo "Releasing for $release_version ($stability)\n\n";
/* Check whether there is a Mantis version */
$project = file_get_contents( "{$url}/projects/{$project_id}" );
$p_info = json_decode( $project );
function findVersion( $p_info, $release_version )
{
$versions = $p_info->projects[0]->versions;
foreach ( $versions as $key => $version )
{
if ( $version->name === $release_version )
{
return $version;
}
}
return false;
}
function getAllFixedIssuesForVersion( $version_id )
{
global $url;
echo "Fetching issues: ";
$page = 1;
$page_size = 100;
$found = [];
do {
$pageUrl = "{$url}/issues?page_size={$page_size}&page={$page}";
echo " {$page}";
$r = json_decode( file_get_contents( $pageUrl ) );
foreach ( $r->issues as $issue )
{
if ( isset( $issue->fixed_in_version ) && $issue->fixed_in_version->id == $version_id )
{
$found[$issue->id] = $issue->summary;
}
}
$page++;
} while( count( $r->issues ) > 0 );
ksort( $found );
echo "\n\n";
return $found;
}
function writePackageXMLInclusion( $release_version, $issues )
{
global $stability;
$date = date( 'Y-m-d' );
$time = date( 'H:i:s' );
$long_date = date( 'D, M d, Y' );
$bugs = '';
foreach ( $issues as $id => $description )
{
$description = htmlspecialchars( $description );
$bugs .= " - Fixed issue #{$id}: {$description}\n";
}
$xml = <<<ENDXML
<date>{$date}</date>
<time>{$time}</time>
<version>
<release>{$release_version}</release>
<api>{$release_version}</api>
</version>
<stability>
<release>{$stability}</release>
<api>{$stability}</api>
</stability>
<license uri="https://xdebug.org/license/1.03" filesource="LICENSE">Xdebug-1.03</license>
<notes>
{$long_date} - Xdebug {$release_version}
= Fixed bugs:
{$bugs}
</notes>
ENDXML;
file_put_contents( '/tmp/package.xml', $xml );
echo "package.xml snippet is at /tmp/package.xml\n";
}
/*
function createVersion( $project_id, $release_version )
{
global $url;
echo "Creating version {$release_version}\n";
$c = curl_init();
curl_setopt($c, CURLOPT_URL, "{$url}/projects/{$project_id}/versions");
curl_setopt($c, CURLOPT_POST, true);
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
curl_setopt($c, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'Authorization: ' . getenv( 'MANTIS_TOKEN' ),
] );
curl_setopt($c, CURLOPT_POSTFIELDS, json_encode(
[
'name' => $release_version,
'released' => false,
'obsolete' => false,
'timestamp' => date( 'Y-m-d' ),
]
));
$result = curl_exec( $c );
curl_close( $c );
print_r( $result );
}
*/
function updateGIT( bool $from_master )
{
shell_exec('git checkout master');
shell_exec('git pull origin master');
if ( !$from_master )
{
shell_exec('git checkout xdebug_3_5');
shell_exec('git pull origin xdebug_3_5');
}
}
function updateTemplateRC( $release_version )
{
$version = strtr( $release_version, '.', ',' );
$file = file_get_contents( 'template.rc' );
$file = preg_replace( '/#define VERSIONDESC.*/', "#define VERSIONDESC $version,1", $file );
$file = preg_replace( '/#define VERSIONSTR.*/', "#define VERSIONSTR \"{$release_version}\"", $file );
$file = preg_replace( '/2002-202. Derick Rethans/', '2002-' . date('Y') . ' Derick Rethans', $file );
file_put_contents( 'template.rc', $file );
}
function updatePhpXdebugH( $release_version )
{
$file = file_get_contents( 'php_xdebug.h' );
$file = preg_replace( '/#define XDEBUG_VERSION.*/', "#define XDEBUG_VERSION \"{$release_version}\"", $file );
$file = preg_replace( '/\(c\) 2002-202./', '(c) 2002-' . date('Y'), $file );
file_put_contents( 'php_xdebug.h', $file );
}
function rebuild()
{
echo "Rebuilding Xdebug binary:\n";
shell_exec('~/bin/rebuild.sh');
}
function updateIniFileInDocs()
{
global $xdebugRepo, $xdebugOrgRepo;
$cwd = getcwd();
chdir( $xdebugOrgRepo );
shell_exec("php html/docs/convert.php > {$xdebugRepo}/xdebug.ini");
chdir( $cwd );
}
function peclPackage()
{
/*
echo "Running 'pecl package':\n";
pcntl_exec( "/usr/local/php/8.0dev/bin/pecl package" );
*/
echo "pecl package\n";
}
function installPeclPackage( $release_version )
{
/*
echo "Installing new PECL package:\n";
pcntl_exec( "/usr/local/php/8.0dev/bin/pecl install -f xdebug-{$release_version}.tgz" );
*/
echo "pecl install -f xdebug-{$release_version}.tgz 2>&1 >/dev/null && php -v\n";
}
function showGitCommands( $release_version )
{
echo "git commit package.xml template.rc php_xdebug.h xdebug.ini composer.json RELEASE_PROCESS.rst -m \"Go with {$release_version}\"\n";
echo "~/bin/tag-sign.sh {$release_version}\n";
echo "git push origin {$release_version}\n";
echo "\n";
}
function createUpdatesSection( $release_version, $issues )
{
global $xdebugOrgRepo;
$version = strtr( $release_version, '.', '_' );
$date = date( 'Y-m-d' );
$bugs = '';
foreach ( $issues as $id => $description )
{
$description = htmlspecialchars( $description );
$bugs .= "<dd>Fixed <?= bug({$id}); ?>: {$description}</dd>\n";
}
$xml = <<<ENDXML
<dt><a name='x_{$version}'></a>[{$date}] — Xdebug {$release_version}</dt>
<dd><h3>Fixed bugs</h3></dd>
{$bugs}
<hr/>
ENDXML;
file_put_contents( '/tmp/updates.php', $xml );
echo "{$xdebugOrgRepo}/views/home/updates.php snippet is at /tmp/update.php\n";
}
function createXdebugVersionPhp( $release_version )
{
global $xdebugOrgRepo;
$xml = <<<ENDXML
public const NOT_SUPPORTED_BEFORE = '3.4';
public const LATEST_VERSION = '{$release_version}';
public const LATEST_WINDOWS_VERSION = '{$release_version}';
private const VERSIONS = [
'7.0' => [ 'src' => '2.8.1', ],
'7.1' => [ 'src' => '2.9.8', 'win' => '2.9.8' ],
'7.2' => [ 'src' => '3.1.6', 'win' => '3.1.6' ],
'7.3' => [ 'src' => '3.1.6', 'win' => '3.1.6' ],
'7.4' => [ 'src' => '3.1.6', 'win' => '3.1.6' ],
'8.0' => [ 'src' => '{$release_version}', 'win' => '{$release_version}' ],
'8.1' => [ 'src' => '{$release_version}', 'win' => '{$release_version}' ],
'8.2' => [ 'src' => '{$release_version}', 'win' => '{$release_version}' ],
'8.3' => [ 'src' => '{$release_version}', 'win' => '{$release_version}' ],
'8.4' => [ 'src' => '{$release_version}', 'win' => '{$release_version}' ],
'8.5' => [ 'src' => '{$release_version}', 'win' => '{$release_version}' ],
];
ENDXML;
file_put_contents( '/tmp/XdebugVersion.php', $xml );
echo "{$xdebugOrgRepo}/src/XdebugVersion.php snippet is at /tmp/XdebugVersion.php\n";
}
function updateDocsController( $release_version )
{
global $xdebugOrgRepo;
global $stability;
$file = file_get_contents( "{$xdebugOrgRepo}/src/Controller/DocsController.php" );
if ( $stability == 'stable' )
{
$file = preg_replace( "@'\[KW:last_release_version\]', '3\..\..'@", "'[KW:last_release_version]', '{$release_version}'", $file );
}
file_put_contents( "{$xdebugOrgRepo}/src/Controller/DocsController.php", $file );
}
function createNewsTemplate( $release_version )
{
global $xdebugOrgRepo;
$version = strtr( $release_version, '.', '_' );
$date = date( 'Y-m-d' );
$text = <<<ENDTXT
Xdebug {$release_version} is out!
<p>
This is a bug fix release that
</p>
<p>
The full list of changes can be found on the
<a href="https://xdebug.org/updates#x_{$version}">updates</a> page.
</p>
<p>
The source code can be found on the
<a href="https://xdebug.org/download#releases">downloads</a> page, and as
usual, Xdebug is installable through <a href="https://pecl.php.net/">PECL</a> and <a
href="https://github.com/php/pie">PIE</a>, and is also available as package
for most Linux distributions.
</p>
<p>
If you find a bug, please file a report at Xdebug's
<a href="https://bugs.xdebug.org">Issue Tracker</a>.
</p>
<!--
<p>
This release also contains a contribution by: <i></i> — Thanks!
</p>
-->
ENDTXT;
file_put_contents( "{$xdebugOrgRepo}/data/news/{$date}.html", $text );
$cwd = getcwd();
chdir( $xdebugOrgRepo );
shell_exec("git add data/news/{$date}.html");
chdir( $cwd );
}
$r = findVersion( $p_info, $release_version );
if ( $r === false )
{
/*
createVersion( $project_id, $release_version );
$r = findVersion( $p_info, $release_version );
*/
die("The version {$release_version} does not exist");
}
echo "Existing version {$release_version}\n";
echo "Checking date: ";
$version_date = preg_match( '/^(20.*)T/', $r->timestamp, $m );
if ( ! $version_date || $m[1] != date('Y-m-d') )
{
echo "\nUpdate version with right date:\nhttps://bugs.xdebug.org/manage_proj_ver_edit_page.php?version_id={$r->id}\n";
}
else
{
echo "OK\n";
}
$issues = getAllFixedIssuesForVersion( $r->id );
if ( count( $issues) == 0 )
{
die("There are no issues for version {$release_version}");
}
updateGIT( $from_master );
updateTemplateRC( $release_version );
updatePhpXdebugH( $release_version );
rebuild();
updateIniFileInDocs();
echo "\nRun the following commands:\n\n";
peclPackage();
installPeclPackage( $release_version );
showGitCommands( $release_version );
writePackageXMLInclusion( $release_version, $issues );
createUpdatesSection( $release_version, $issues );
if ( $stability === 'stable' )
{
createXdebugVersionPhp( $release_version );
}
updateDocsController( $release_version );
createNewsTemplate( $release_version );
echo "\nSet version 'release' to 'true':\nhttps://bugs.xdebug.org/manage_proj_ver_edit_page.php?version_id={$r->id}\n";