Skip to content

Commit 41cd87c

Browse files
committed
Use script instead of draft release to prepare release
GitHub does not fire release events for draft releases, so the release-prepare workflow could never trigger. Replace it with an interactive local script (bin/prepare-release.sh) that bumps versions, generates a changelog from merged PRs, and creates a release branch. Rework release-publish to build the plugin zip and create a GitHub release when the release PR is merged to trunk.
1 parent ac03c08 commit 41cd87c

6 files changed

Lines changed: 214 additions & 189 deletions

File tree

.github/workflows/release-prepare.yml

Lines changed: 0 additions & 155 deletions
This file was deleted.

.github/workflows/release-publish.yml

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@ on:
55
types: [closed]
66
branches: [trunk]
77

8+
concurrency:
9+
group: release-publish
10+
cancel-in-progress: false
11+
812
jobs:
913
publish-release:
10-
name: Publish draft release
14+
name: Build plugin and create GitHub release
1115
if: >-
1216
github.repository == 'WordPress/sqlite-database-integration'
1317
&& github.event.pull_request.merged == true
@@ -30,21 +34,46 @@ jobs:
3034
echo "version=$VERSION" >> $GITHUB_OUTPUT
3135
echo "tag=v$VERSION" >> $GITHUB_OUTPUT
3236
33-
- name: Publish draft release
37+
- name: Set up PHP
38+
uses: shivammathur/setup-php@v2
39+
with:
40+
php-version: '8.2'
41+
42+
- name: Build plugin zip
43+
run: composer run build-sqlite-plugin-zip
44+
45+
- name: Extract changelog from readme.txt
46+
id: changelog
47+
env:
48+
VERSION: ${{ steps.version.outputs.version }}
49+
run: |
50+
README="packages/plugin-sqlite-database-integration/readme.txt"
51+
52+
# Extract the changelog entry for this version.
53+
CHANGELOG=$(awk -v version="$VERSION" '
54+
$0 == "= " version " =" { found = 1; next }
55+
found && /^= / { exit }
56+
found { print }
57+
' "$README" | sed -e '/./,$!d' -e :a -e '/^\s*$/{ $d; N; ba; }') # Trim leading/trailing blank lines.
58+
59+
{
60+
echo "body<<CHANGELOG_EOF"
61+
echo "$CHANGELOG"
62+
echo "CHANGELOG_EOF"
63+
} >> $GITHUB_OUTPUT
64+
65+
- name: Create GitHub release
3466
env:
3567
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3668
TAG: ${{ steps.version.outputs.tag }}
3769
MERGE_SHA: ${{ github.event.pull_request.merge_commit_sha }}
70+
BODY: ${{ steps.changelog.outputs.body }}
3871
run: |
39-
# Get the current release body and remove the PR note.
40-
BODY=$(gh release view "$TAG" --json body --jq '.body' 2>/dev/null || echo "")
41-
CLEAN_BODY=$(echo "$BODY" | grep -v "^> To publish the release, review and merge:")
42-
43-
# Publish the release, targeting the merge commit.
44-
gh release edit "$TAG" \
45-
--draft=false \
72+
gh release create "$TAG" \
4673
--target "$MERGE_SHA" \
47-
--notes "$CLEAN_BODY"
74+
--title "$TAG" \
75+
--notes "$BODY" \
76+
"build/sqlite-database-integration.zip"
4877
4978
- name: Delete release branch
5079
env:

AGENTS.md

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ composer install # Install dependencies
4646
composer run check-cs # Check coding standards (PHPCS)
4747
composer run fix-cs # Auto-fix coding standards (PHPCBF)
4848
composer run build-sqlite-plugin-zip # Build the plugin zip
49+
composer run prepare-release # Prepare a new release
4950

5051
# SQLite driver tests (under packages/mysql-on-sqlite)
5152
cd packages/mysql-on-sqlite
@@ -69,18 +70,25 @@ composer run wp-test-clean # Clean up WordPress environment (Docker
6970
```
7071

7172
## Release workflow
72-
Release is automated with GitHub Actions. It requires only two manual steps:
73-
74-
1. **Create a draft release with a new tag and changelog.**
75-
The `release-prepare` workflow will automatically:
76-
- Use the draft tag to bump versions in `version.php`, `load.php`, and `readme.txt`.
77-
- Add the draft release changelog entry to `readme.txt`.
78-
- Build the plugin ZIP and attach it to the draft release.
79-
- Create a PR (`release/<version>``trunk`) and link it in the draft release body.
80-
2. **Review and merge the PR.**
81-
The `release-publish` workflow will automatically:
82-
- Publish the draft release.
83-
- Publish the release artifact to WordPress.org.
73+
Release is streamlined with a local preparation script and GitHub Actions:
74+
75+
1. **Run the release preparation script locally.**
76+
```bash
77+
composer run prepare-release -- <version>
78+
```
79+
The script will:
80+
- Bump version numbers and generate a changelog from merged PRs.
81+
- Create a `release/<version>` branch with a preparation commit.
82+
- Push the branch and create a PR.
83+
84+
2. **Review the PR.**
85+
Edit the changelog or push additional changes to the release branch.
86+
87+
3. **Mark as ready and merge the PR.**
88+
The `release-publish` workflow will automatically:
89+
- Build the plugin ZIP.
90+
- Create and publish a GitHub release with the ZIP attached.
91+
- Deploy the release to WordPress.org.
8492

8593
## Architecture
8694
The project consists of multiple components providing different APIs that funnel

README.md

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ composer install # Install dependencies
3535
composer run check-cs # Check coding standards (PHPCS)
3636
composer run fix-cs # Auto-fix coding standards (PHPCBF)
3737
composer run build-sqlite-plugin-zip # Build the plugin zip
38+
composer run prepare-release # Prepare a new release
3839

3940
# SQLite driver tests (under packages/mysql-on-sqlite)
4041
cd packages/mysql-on-sqlite
@@ -58,18 +59,25 @@ composer run wp-test-clean # Clean up WordPress environment (Docker
5859
```
5960

6061
## Release workflow
61-
Release is automated with GitHub Actions. It requires only two manual steps:
62-
63-
1. **Create a draft release with a new tag and changelog.**
64-
The `release-prepare` workflow will automatically:
65-
- Use the draft tag to bump versions in `version.php`, `load.php`, and `readme.txt`.
66-
- Add the draft release changelog entry to `readme.txt`.
67-
- Build the plugin ZIP and attach it to the draft release.
68-
- Create a PR (`release/<version>``trunk`) and link it in the draft release body.
69-
2. **Review and merge the PR.**
70-
The `release-publish` workflow will automatically:
71-
- Publish the draft release.
72-
- Publish the release artifact to WordPress.org.
62+
Release is streamlined with a local preparation script and GitHub Actions:
63+
64+
1. **Run the release preparation script locally.**
65+
```bash
66+
composer run prepare-release -- <version>
67+
```
68+
The script will:
69+
- Bump version numbers and generate a changelog from merged PRs.
70+
- Create a `release/<version>` branch with a preparation commit.
71+
- Push the branch and create a PR.
72+
73+
2. **Review the PR.**
74+
Edit the changelog or push additional changes to the release branch.
75+
76+
3. **Mark as ready and merge the PR.**
77+
The `release-publish` workflow will automatically:
78+
- Build the plugin ZIP.
79+
- Create and publish a GitHub release with the ZIP attached.
80+
- Deploy the release to WordPress.org.
7381

7482
## Architecture
7583
The project consists of multiple components providing different APIs that funnel

0 commit comments

Comments
 (0)