Skip to content

Commit d9492e4

Browse files
authored
Rework release workflow (#350)
## Summary Replace the draft-release-triggered CI workflow with a local `prepare-release.sh` script and a simplified publish workflow. GitHub does not fire `release` events for draft releases, so the `release-prepare` workflow could never trigger. The new approach uses a non-interactive script (`bin/prepare-release.sh <version>`) that bumps versions, generates a changelog from merged PRs, creates a release branch, and opens a PR. Merging the PR triggers the build and GitHub release automatically. Also adds pre-release support: versions with a hyphen (e.g., `2.3.0-beta.1`) are marked as pre-release and skip WordPress.org deployment.
1 parent ac03c08 commit d9492e4

7 files changed

Lines changed: 245 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: 51 additions & 9 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,59 @@ jobs:
3034
echo "version=$VERSION" >> $GITHUB_OUTPUT
3135
echo "tag=v$VERSION" >> $GITHUB_OUTPUT
3236
33-
- name: Publish draft release
37+
# Versions with a hyphen (e.g., 2.3.0-beta.1) are prereleases.
38+
if [[ "$VERSION" == *-* ]]; then
39+
echo "prerelease=true" >> $GITHUB_OUTPUT
40+
else
41+
echo "prerelease=false" >> $GITHUB_OUTPUT
42+
fi
43+
44+
- name: Set up PHP
45+
uses: shivammathur/setup-php@v2
46+
with:
47+
php-version: '8.2'
48+
49+
- name: Build plugin zip
50+
run: composer run build-sqlite-plugin-zip
51+
52+
- name: Extract changelog from readme.txt
53+
id: changelog
54+
env:
55+
VERSION: ${{ steps.version.outputs.version }}
56+
run: |
57+
README="packages/plugin-sqlite-database-integration/readme.txt"
58+
59+
# Extract the changelog entry for this version.
60+
CHANGELOG=$(awk -v version="$VERSION" '
61+
$0 == "= " version " =" { found = 1; next }
62+
found && /^= / { exit }
63+
found { print }
64+
' "$README" | sed -e '/./,$!d' -e :a -e '/^\s*$/{ $d; N; ba; }') # Trim leading/trailing blank lines.
65+
66+
{
67+
echo "body<<CHANGELOG_EOF"
68+
echo "$CHANGELOG"
69+
echo "CHANGELOG_EOF"
70+
} >> $GITHUB_OUTPUT
71+
72+
- name: Create GitHub release
3473
env:
3574
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3675
TAG: ${{ steps.version.outputs.tag }}
3776
MERGE_SHA: ${{ github.event.pull_request.merge_commit_sha }}
77+
BODY: ${{ steps.changelog.outputs.body }}
3878
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:")
79+
PRERELEASE_FLAG=""
80+
if [[ "${{ steps.version.outputs.prerelease }}" == "true" ]]; then
81+
PRERELEASE_FLAG="--prerelease"
82+
fi
4283
43-
# Publish the release, targeting the merge commit.
44-
gh release edit "$TAG" \
45-
--draft=false \
84+
gh release create "$TAG" \
4685
--target "$MERGE_SHA" \
47-
--notes "$CLEAN_BODY"
86+
--title "$TAG" \
87+
--notes "$BODY" \
88+
$PRERELEASE_FLAG \
89+
"build/sqlite-database-integration.zip"
4890
4991
- name: Delete release branch
5092
env:

.github/workflows/release-wporg.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ concurrency:
1111
jobs:
1212
deploy:
1313
name: Deploy plugin to WordPress.org
14-
if: github.repository == 'WordPress/sqlite-database-integration'
14+
if: >-
15+
github.repository == 'WordPress/sqlite-database-integration'
16+
&& github.event.release.prerelease == false
1517
runs-on: ubuntu-latest
1618
environment: WordPress.org
1719
permissions:

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)