Check versions before you release
Stop a release when the plugin header, readme Stable tag, PHP constants and git tag disagree.
version-check compares the versions that have to agree before a release. WordPress.org shows the readme Stable tag, installs read the Version header, and a mismatch ships the wrong version.
npx @wpelevator/wp-release version-check
Error: Stable tag in readme.txt is 1.4.1, expected 1.4.2.
The command exits with 2, so it stops a CI job. After fixing the readme:
All versions match 1.4.2.
Name the PHP constants that hold the version too:
npx @wpelevator/wp-release version-check --constant MY_PLUGIN_VERSION
All versions match 1.4.2.
In GitHub Actions, each mismatch is also an annotation on the file and line of the version: see annotations and job summaries.
What it checks
version-check compares the versions that have to agree before a release, and reports every mismatch with exit code 2:
wp-release version-check --constant MY_PLUGIN_VERSION --git-tag v1.2.0
- The expected version is
--version, or theVersionheader. - The readme
Stable tagmust match for plugins;--no-stable-tagskips it, and themes have no Stable tag. --constant NAME(repeatable) checksdefine( 'NAME', '1.2.0' )orconst NAME = '1.2.0'in every PHP file outsidevendor/,node_modules/and dot directories. A constant that isn't defined is a mismatch.--git-tagdefaults toGITHUB_REFwhen it's a tag.--git-tag-format(default{version}) can have a prefix or the slug, likev{version}or{slug}-{version}; a leadingvin the version is ignored, like for SVN tags.