Working with WordPress.org SVN Cheat Sheet
After years of building and releasing plugins on the WordPress.org repository you learn a few things about SVN usage.
Since most of us use Git via Github or similar to manage the actual code and day to day changes, we must use SVN from time to time to get a release out to the public.
I’ve put together the following cheat sheet for WordPress.org SVN usage that has some optimized commands for doing the necessary stuff very quickly.
I know there are some good Github actions and workflows to automate this, but some times it just helps to have a few quick CLI commands that work.
Hope you find them helpful.
Checkout Trunk Only (Preferred)
If you don’t need to compare versioned tags or modify wordpress.org plugin page assets this is the ideal way to do it by only downloading the
/trunk working branch.
To check out only the trunk working branch you will use the following methodology, replacing
plugin-name with the correct plugin slug.
svn checkout --depth empty https://plugins.svn.wordpress.org/plugin-name/ plugin-name svn update --set-depth infinity plugin-name/trunk
Checkout WordPress Page Assets Only
To modify banner images or plugin icons this will get the correct folder set up.
svn checkout --depth empty https://plugins.svn.wordpress.org/plugin-name/ plugin-name svn update --set-depth infinity plugin-name/assets
Remove Missing Files
Remove files that have been deleted since last release.
svn st | grep "!" | cut -d! -f2 | sed 's/^ *//' | xargs -n 500 -d "\n" -r svn rm
Add New Files
Add files that were created since last release.
svn st | grep ^? | cut -d? -f2 | sed 's/^ *//' | xargs -n 500 -d "\n" -r svn add
Fix Asset Content-Type
This only applies to the wordpress.org plugin
/assets directory which needs to serve these files as images, not as binary data like the SVN repository does.
svn propset svn:mime-type image/png *.png svn propset svn:mime-type image/jpeg *.jpg svn propset svn:mime-type image/gif *.gif svn propset svn:mime-type image/svg+xml *.svg svn propset svn:mime-type image/svg+xml *.svgz
Commit Trunk Changes
Make sure to to run an
svn st and double check everything looks right before proceeding. You would immediately follow this by tagging the release remotely, found below.
cd plugin-name/trunk svn ci -m "Updating code to release vx.x.x" # Example Output > Enter your wordpress.org username > Enter your wordpress.org password > Sending trunk/plugin-name.php > Transmitting file data ................................. > Committing transaction... > Committed revision 2687342.
Tagging Release Remotely
When working with only the
/trunk branch locally this method allows first pushing the trunk updates, then remotely copying
/trunk to a new versioned folder in the
/tags directory on the remote SVN repository such as
svn copy https://plugins.svn.wordpress.org/plugin-name/trunk \ https://plugins.svn.wordpress.org/plugin-name/tags/1.0.0 \ -m "Tagging the 1.0.0 release" # Example Output > Enter your wordpress.org username > Enter your wordpress.org password > Committing transaction... > Committed revision 2687342.
Update already tagged readme
Sometimes you need to update just the readme.txt file. This can be done easily with only the
/trunk branch locally. Update
1.0.0 version according to your needs.
First modify the readme.txt file then use the following.
cd plugin-name/trunk svn ci -m "Readme update" readme.txt # Remove the readme in the latest tag folder. svn rm -m "Remove outdated readme" \ https://plugins.svn.wordpress.org/plugin-name/tags/1.0.0/readme.txt # Copy new trunk/readme to the latest tag folder. svn copy -m "Updating readme for existing tag" readme.txt \ https://plugins.svn.wordpress.org/plugin-name/tags/1.0.0
Daniel Iser is a professional WordPress plugin developer, and the author of plugins such as Easy Modal & Popup Maker. Founder of Wizard Internet Solutions he has been working with WordPress for over 7 years creating websites and tools for clients & blog authors.
Leave a Comment