This directory contains scripts that support the release process for the WPGraphQL monorepo.
Updates the Upgrade Notice section in readme.txt when there are breaking changes in a release.
Purpose: WordPress.org displays upgrade notices to users before they update a plugin. This script ensures users are warned about breaking changes.
Usage:
node scripts/update-upgrade-notice.js --version=X.Y.Z --plugin-dir=plugins/wp-graphqlArguments:
| Argument | Required | Description |
|---|---|---|
--version |
Yes | The version to check for breaking changes |
--plugin-dir |
No | Path to plugin directory (default: plugins/wp-graphql) |
How it works:
- Reads
CHANGELOG.mdin the specified plugin directory - Extracts breaking changes for the specified version (looks for
### ⚠ BREAKING CHANGESsection) - If breaking changes exist, updates the
== Upgrade Notice ==section inreadme.txt - Preserves PR links and scope prefixes (e.g.,
**resolver:**)
Example output in readme.txt:
== Upgrade Notice ==
= 3.0.0 =
**⚠️ BREAKING CHANGES**: This release contains breaking changes that may require updates to your code.
* Remove deprecated `singlePost` query in favor of `post` query ([#1234](https://github.com/wp-graphql/wp-graphql/pull/1234))
* Change default pagination limit from 100 to 50 items ([#1235](https://github.com/wp-graphql/wp-graphql/pull/1235))
Please review these changes before upgrading.
Updates version constants and Version headers in plugin files during the release PR update process.
Purpose: Ensures that version numbers in PHP constants and plugin headers are synchronized when release-please creates a Release PR.
Usage:
node scripts/update-version-constants.js --version=X.Y.Z --component=wp-graphql --plugin-dir=plugins/wp-graphqlArguments:
| Argument | Required | Description |
|---|---|---|
--version |
Yes | The version number to set |
--component |
Yes | Component name (e.g., wp-graphql, wp-graphql-smart-cache, wp-graphql-acf) |
--plugin-dir |
Yes | Path to plugin directory (relative to repo root) |
How it works:
- Reads
release-please-config.jsonto get theconstantMapfor the component - Updates the version constant (e.g.,
WPGRAPHQL_VERSION) in the specified file - Updates the
Version:header in the main plugin file - Updates the
@versiondocblock tag if present
Configuration:
Version constant mappings are configured in release-please-config.json under each plugin's constantMap key:
"plugins/your-plugin-name": {
"component": "your-plugin-name",
"constantMap": {
"constantName": "YOUR_PLUGIN_VERSION",
"fileName": "your-plugin-name.php",
"mainPluginFile": "your-plugin-name.php"
}
}Configuration fields:
constantName: The PHP constant name (e.g.,YOUR_PLUGIN_VERSION)fileName: The file containing the constant definitionmainPluginFile: The main plugin file with theVersion:header
Note: When adding a new plugin, simply add the constantMap to release-please-config.json. No code changes to the script are needed!
# Run from repo root
npm run test:scriptsTests are located in update-upgrade-notice.test.js and cover:
| Test Case | Description |
|---|---|
| Standard format | Extracts breaking changes from release-please CHANGELOG format |
| No breaking changes | Handles versions without breaking changes gracefully |
| Version not found | Handles missing version in changelog |
| Update existing | Updates existing upgrade notice without duplicating |
| Alternative headers | Handles ### BREAKING CHANGES (without emoji) |
| Version formats | Handles both ## [1.0.0] and ## 1.0.0 formats |
| Multiple versions | Extracts changes for correct version only |
| Scope prefixes | Preserves **scope:** prefixes in changes |
Tests run automatically via .github/workflows/test-scripts.yml:
- On push/PR when
scripts/**changes - Monthly (1st of each month)
- Manually via workflow_dispatch
These scripts are called by GitHub Actions workflows during the release process:
┌─────────────────────┐
│ PR Merged to main │
└──────────┬──────────┘
│
▼
┌─────────────────────┐
│ release-please │
│ creates Release PR │
└──────────┬──────────┘
│
▼
┌─────────────────────┐
│ update-release-pr │◄── Runs update-upgrade-notice.js
│ workflow │ if breaking changes detected
└──────────┬──────────┘
│
▼
┌─────────────────────┐
│ Release PR Merged │
└──────────┬──────────┘
│
▼
┌─────────────────────┐
│ Deploy to WP.org │
└─────────────────────┘
When adding new release scripts:
- Place the script in this directory
- Add tests in a corresponding
.test.jsfile - Update
package.jsonif a new npm script is needed - Document the script in this README
- Update
.github/workflows/test-scripts.ymlif needed