From 12a84c4900b4d65f535d5e9d03daa4ba48fbfda3 Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Tue, 30 Jan 2024 15:06:17 +0100 Subject: [PATCH 1/2] Bump --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 87b1e45..da7a887 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install PHP uses: shivammathur/setup-php@v2 @@ -38,7 +38,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install PHP uses: shivammathur/setup-php@v2 @@ -68,7 +68,7 @@ jobs: steps: - name: "Checkout" - uses: "actions/checkout@v3" + uses: "actions/checkout@v4" - name: "Install PHP with extensions" uses: "shivammathur/setup-php@v2" From 3a40170ffb5b8bedda143835a35a041f38fbf225 Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Sun, 10 Mar 2024 13:28:54 +0100 Subject: [PATCH 2/2] Create release when tag is pushed --- .github/workflows/release.yaml | 39 +++++++++++++++++++++ build/scripts/extract-release-notes.php | 46 +++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 .github/workflows/release.yaml create mode 100755 build/scripts/extract-release-notes.php diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..2557ae9 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,39 @@ +# https://docs.github.com/en/actions + +on: + push: + tags: + - "**" + +name: Release + +jobs: + release: + name: Release + + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install PHP with extensions + uses: shivammathur/setup-php@v2 + with: + php-version: 8.3 + coverage: none + extensions: none + tools: none + + - name: Determine tag + run: echo "RELEASE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + + - name: Parse ChangeLog + run: build/scripts/extract-release-notes.php ${{ env.RELEASE_TAG }} > release-notes.md + + - name: Create release + uses: ncipollo/release-action@v1 + with: + bodyFile: release-notes.md + tag: ${{ env.RELEASE_TAG }} + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/build/scripts/extract-release-notes.php b/build/scripts/extract-release-notes.php new file mode 100755 index 0000000..5531892 --- /dev/null +++ b/build/scripts/extract-release-notes.php @@ -0,0 +1,46 @@ +#!/usr/bin/env php +' . PHP_EOL; + + exit(1); +} + +$version = $argv[1]; + +$file = __DIR__ . '/../../ChangeLog.md'; + +if (!is_file($file) || !is_readable($file)) { + print $file . ' cannot be read' . PHP_EOL; + + exit(1); +} + +$buffer = ''; +$append = false; + +foreach (file($file) as $line) { + if (str_starts_with($line, '## [' . $version . ']')) { + $append = true; + + continue; + } + + if ($append && (str_starts_with($line, '## ') || str_starts_with($line, '['))) { + break; + } + + if ($append) { + $buffer .= $line; + } +} + +$buffer = trim($buffer); + +if ($buffer === '') { + print 'Unable to extract release notes' . PHP_EOL; + + exit(1); +} + +print $buffer . PHP_EOL;