-
-
Notifications
You must be signed in to change notification settings - Fork 265
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
178 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<package version="2.1" xmlns="http://pear.php.net/dtd/package-2.1" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.1 http://pear.php.net/dtd/package-2.1.xsd"> | ||
<package xmlns="http://pear.php.net/dtd/package-2.1" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.1" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.1 http://pear.php.net/dtd/package-2.1.xsd"> | ||
<name>rdkafka</name> | ||
<channel>pecl.php.net</channel> | ||
<summary>Kafka client based on librdkafka</summary> | ||
|
@@ -10,10 +10,10 @@ | |
<email>[email protected]</email> | ||
<active>yes</active> | ||
</lead> | ||
<date>2022-06-12</date> | ||
<time>12:00:00</time> | ||
<date>2022-07-02</date> | ||
<time>12:26:56</time> | ||
<version> | ||
<release>6.0.2</release> | ||
<release>6.0.3</release> | ||
<api>6.0.0</api> | ||
</version> | ||
<stability> | ||
|
@@ -22,8 +22,8 @@ | |
</stability> | ||
<license uri="http://opensource.org/licenses/mit-license.php">MIT License</license> | ||
<notes> | ||
## Bugfixes | ||
- Fixed signature of RdKafka\KafkaConsumer::getMetadata() (#521, @arnaud-lb) | ||
## Improvements | ||
- Ability to provide custom `librdkafka` path during install (#526, @Wirone) | ||
</notes> | ||
<contents> | ||
<dir name="/"> | ||
|
@@ -160,6 +160,23 @@ | |
<configureoption name="with-rdkafka" default="autodetect" prompt="librdkafka installation path?"/> | ||
</extsrcrelease> | ||
<changelog> | ||
<release> | ||
<date>2022-06-12</date> | ||
<time>12:00:00</time> | ||
<version> | ||
<release>6.0.2</release> | ||
<api>6.0.0</api> | ||
</version> | ||
<stability> | ||
<release>stable</release> | ||
<api>stable</api> | ||
</stability> | ||
<license uri="http://opensource.org/licenses/mit-license.php">MIT License</license> | ||
<notes> | ||
## Bugfixes | ||
- Fixed signature of RdKafka\KafkaConsumer::getMetadata() (#521, @arnaud-lb) | ||
</notes> | ||
</release> | ||
<release> | ||
<date>2022-02-15</date> | ||
<time>12:00:00</time> | ||
|
@@ -194,8 +211,8 @@ | |
|
||
## Improvements | ||
- PHP 8.1 support (@remicollet, @ruudk, @nick-zh) | ||
- Added parameter types (when built with PHP>=8.0) (@arnaud-lb) | ||
- Added tentative return types (when built with PHP>=8.1) (@arnaud-lb) | ||
- Added parameter types (when built with PHP>=8.0) (@arnaud-lb) | ||
- Added tentative return types (when built with PHP>=8.1) (@arnaud-lb) | ||
|
||
## Deprecations | ||
- PHP 8.1: Overloading php-rdkafka methods without specifying a return type | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
|
||
const NS = 'http://pear.php.net/dtd/package-2.1'; | ||
|
||
if (!isset($argv[1])) { | ||
fprintf(STDERR, "Missing version parameter\n"); | ||
printUsage(); | ||
exit(1); | ||
} | ||
|
||
$newVersion = $argv[1]; | ||
|
||
$doc = new DOMDocument(); | ||
if (!$doc->load(__DIR__.'/../package.xml')) { | ||
throw new \Exception('Failed loading package.xml'); | ||
} | ||
|
||
$releaseNotes = generateReleaseNotes($newVersion); | ||
|
||
moveCurrentReleaseToChangelog($doc); | ||
updateCurrentRelease($doc, $newVersion, $releaseNotes); | ||
|
||
file_put_contents(__DIR__.'/../package.xml', $doc->saveXML()); | ||
|
||
function printUsage(): void | ||
{ | ||
fprintf(STDERR, "Usage: %s <version>\n", $_SERVER['argv'][0]); | ||
} | ||
|
||
function generateReleaseNotes(string $newVersion): string | ||
{ | ||
$cmd = sprintf( | ||
'gh api repos/arnaud-lb/php-rdkafka/releases/generate-notes -f tag_name=%s', | ||
escapeshellcmd($newVersion), | ||
); | ||
|
||
$result = exec($cmd); | ||
if ($result === false) { | ||
throw new \Exception(sprintf('Command `%s` failed', $cmd)); | ||
} | ||
|
||
$lines = explode("\n", json_decode($result, true)['body']); | ||
|
||
$newLines = []; | ||
$add = false; | ||
foreach ($lines as $line) { | ||
if (str_starts_with($line, '###')) { | ||
$add = true; | ||
$line = substr($line, 1); | ||
} elseif (str_starts_with($line, '##')) { | ||
$add = false; | ||
} | ||
if ($add) { | ||
$line = preg_replace( | ||
'# by (@[^ ]+) in https://github.com/[^ ]+/pull/([0-9]+)#', | ||
' (#\2, \1)', | ||
$line, | ||
); | ||
$line = preg_replace( | ||
'#^\*#', | ||
'-', | ||
$line, | ||
); | ||
$newLines[] = $line; | ||
} | ||
} | ||
|
||
return implode("\n", $newLines); | ||
} | ||
|
||
function updateCurrentRelease(DOMDocument $doc, string $newVersion, string $releaseNotes): void | ||
{ | ||
$date = date('Y-m-d'); | ||
$time = date('H:i:s'); | ||
|
||
$dateElem = findOneElement($doc, '/ns:package/ns:date'); | ||
replaceContent($dateElem, $doc->createTextNode($date)); | ||
|
||
$timeElem = findOneElement($doc, '/ns:package/ns:time'); | ||
replaceContent($timeElem, $doc->createTextNode($time)); | ||
|
||
$versionElem = findOneElement($doc, '/ns:package/ns:version/ns:release'); | ||
replaceContent($versionElem, $doc->createTextNode($newVersion)); | ||
|
||
$notesElem = findOneElement($doc, '/ns:package/ns:notes'); | ||
$releaseNotes = rtrim("\n " . str_replace("\n", "\n ", $releaseNotes))."\n "; | ||
replaceContent($notesElem, $doc->createTextNode($releaseNotes)); | ||
} | ||
|
||
function moveCurrentReleaseToChangelog(DOMDocument $doc): void | ||
{ | ||
$oldRelease = $doc->createElementNS(NS, 'release'); | ||
$oldRelease->appendChild($doc->createTextNode("\n")); | ||
|
||
$nodesToCopy = ['date', 'time', 'version', 'stability', 'license', 'notes']; | ||
|
||
foreach ($nodesToCopy as $nodeName) { | ||
$path = sprintf('/ns:package/ns:%s', $nodeName); | ||
$elem = findOneElement($doc, $path); | ||
|
||
$elem = $elem->cloneNode(true); | ||
|
||
$oldRelease->appendChild($doc->createTextNode(" ")); | ||
$oldRelease->appendChild($elem); | ||
$oldRelease->appendChild($doc->createTextNode("\n")); | ||
} | ||
|
||
indent($oldRelease, ' '); | ||
|
||
$changelogElem = findOneElement($doc, '/ns:package/ns:changelog'); | ||
$changelogElem->insertBefore($oldRelease, $changelogElem->firstChild); | ||
$changelogElem->insertBefore($doc->createTextNode("\n "), $oldRelease); | ||
} | ||
|
||
function findOneElement(DOMDocument $doc, string $path): DOMElement | ||
{ | ||
$xp = new DOMXPath($doc, false); | ||
$xp->registerNamespace('ns', NS); | ||
|
||
$list = $xp->evaluate($path); | ||
if ($list->length !== 1) { | ||
throw new \Exception(sprintf( | ||
'XPath expression %s expected to find 1 element, but found %d', | ||
$path, | ||
$list->length, | ||
)); | ||
} | ||
|
||
return $list->item(0); | ||
} | ||
|
||
function indent(DOMElement $elem, string $indentString): void | ||
{ | ||
foreach ($elem->childNodes as $node) { | ||
if ($node instanceof DOMText) { | ||
$node->textContent = str_replace("\n", "\n".$indentString, $node->textContent); | ||
} else if ($node instanceof DOMElement) { | ||
indent($node, $indentString); | ||
} | ||
} | ||
} | ||
|
||
function replaceContent(DOMElement $elem, DOMNode $newContent): void | ||
{ | ||
while ($elem->firstChild !== null) { | ||
$elem->removeChild($elem->firstChild); | ||
} | ||
|
||
$elem->appendChild($newContent); | ||
} | ||
|