Skip to content

Commit 413f7cc

Browse files
committed
Automation
1 parent 9fca571 commit 413f7cc

File tree

3 files changed

+92
-0
lines changed

3 files changed

+92
-0
lines changed

.github/workflows/release.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# https://help.github.com/en/categories/automating-your-workflow-with-github-actions
2+
3+
name: "Create release"
4+
5+
on:
6+
push:
7+
tags:
8+
- '*'
9+
10+
concurrency: release
11+
12+
jobs:
13+
create_release:
14+
name: "Create release"
15+
runs-on: "ubuntu-latest"
16+
17+
steps:
18+
- name: "Checkout"
19+
uses: actions/checkout@v3
20+
21+
- name: "Generate release notes"
22+
run: ./tools/extract-release-notes.php > ${{ github.workspace }}-CHANGELOG.txt
23+
24+
- name: "Create release"
25+
uses: softprops/action-gh-release@v1
26+
with:
27+
# token: ${{ secrets.BOT_TOKEN }}
28+
draft: true
29+
discussion_category_name: "General"
30+
body_path: ${{ github.workspace }}-CHANGELOG.txt

tools/extract-release-notes.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
const NS = 'http://pear.php.net/dtd/package-2.1';
5+
6+
$doc = new DOMDocument();
7+
if (!$doc->load(__DIR__.'/../package.xml')) {
8+
throw new \Exception('Failed loading package.xml');
9+
}
10+
11+
$notesElem = findOneElement($doc, '/ns:package/ns:notes');
12+
echo $notesElem->textContent;
13+
14+
function findOneElement(DOMDocument $doc, string $path): DOMElement
15+
{
16+
$xp = new DOMXPath($doc, false);
17+
$xp->registerNamespace('ns', NS);
18+
19+
$list = $xp->evaluate($path);
20+
if ($list->length !== 1) {
21+
throw new \Exception(sprintf(
22+
'XPath expression %s expected to find 1 element, but found %d',
23+
$path,
24+
$list->length,
25+
));
26+
}
27+
28+
return $list->item(0);
29+
}

tools/prepare-release.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
version="$1"
6+
baseBranch=6.x
7+
8+
if [[ -z "$version" ]]; then
9+
printf "Missing version parameter" >&2
10+
printf "Usage: %s <version>\n" "$0" >&2
11+
exit 1
12+
fi
13+
14+
echo "Updating package.xml"
15+
./tools/new-package-release.php "$1"
16+
pecl package-validate
17+
18+
echo "Updating PHP_RDKAFKA_VERSION"
19+
sed -i 's/#define PHP_RDKAFKA_VERSION.*/#define PHP_RDKAFKA_VERSION "'"$1"'"/' php_rdkafka.h
20+
21+
echo "Printing diff"
22+
git diff
23+
24+
read -p "Commit and send pull request for version $version ? [n/N]" -n 1 -r
25+
echo
26+
if ! [[ $REPLY =~ ^[Yy]$ ]]; then
27+
echo "Ok, aborting"
28+
exit 1
29+
fi
30+
31+
git checkout -b "release/$version" "$baseBranch"
32+
git commit package.xml php_rdkafka.h -m "$1"
33+
gh pr create --fill --label release --base "$baseBranch"

0 commit comments

Comments
 (0)