Improve your WordPress Plugin Deployment

Improve your WordPress Plugin Deployment

We hate SVN. At least most of us do. We all love GitHub (or Bitbucket, GitLab or similar). Yet, we wanna do WordPress plugins and put them up in the plugin repository.

There comes a time when everyone needs to get in touch with SVN, which is not wrong. As a developer, you should be familiar with it so that you can contribute to WordPress Core. 🙂  But using SVN to manage your plugin is a pain, especially since you probably have all development happen on a platform like GitHub. Fortunately, it doesn’t need to be like that. There are ways to deploy new plugin releases without even knowing that SVN is being used. Even if you love SVN to death, a deploy script for your plugins is worth using – let me introduce one to you in this post.

Releasing a new plugin version

The manual approach

What do you need to do when releasing a new version of your plugin? You have your local Git project repository directory somewhere on your machine and the plugin’s local SVN repository somewhere else. To release a new version, you need to copy everything over into the /trunk directory of your SVN repo. You need to take care of not copying development-related files (.gitignore, .travis.yml etc) since these should not reside in your actual WordPress plugin. Then you need to tell SVN to explicitly add/remove any new/missing files. Then commit it. Then tag a new release. Phew! You lose a few minutes of your life here for every plugin release. Maintaining the plugin’s assets (banner, icon and screenshots) adds up to this routine.

The automated approach

Wouldn’t it be nice to be able to only type in sh ./deploy.sh into your console and have it do all that annoying stuff for you? Luckily there’s a deploy script that does exactly that, created by Dominik Schilling, release lead of WordPress 4.6. The deploy script is part of one of his repositories which bundles a bunch of useful scripts when dealing with plugins, so you might wanna check out the others as well.

All you need to do to speed up your WordPress plugin deployment is include that file in your plugin’s project and update the PLUGINSLUG variable to your plugin’s slug. After that, you just need to make sure you specify a new version number in your plugin’s main file and readme for every release, and a sh ./deploy.sh will do its magic then. This script also allows you to manage the plugin assets: Simply add a directory called assets-wp-repo to your plugin project and put the necessary images into it – the deploy script will then take care of ensuring that these are pushed to the SVN repository correctly.

The cool thing about using such a script is that you can of course adjust how it works, so that it fits your specific requirements perfectly. What I definitely recommend you to do is to adjust the list of files that should be ignored by SVN so that they are not included in your plugin – all purely development-related files your plugin uses should probably be in that list. But you can also do completely custom stuff. For example, Bernhard Kau handles Git submodules in his deploy script while I take care of Composer dependencies in mine – whatever you use there, it makes sure that all dependencies are included in your plugin appropriately (if your plugin has any). If have never worked with shell scripts, I would encourage you to get at least a bit familiar with it – you will be able to do powerful stuff then.

More ideas?

So that’s it for the introduction to this great script. What you do with it, if and how you enhance it, is up to you. Are you doing some cool things with your deploy scripts that might be useful for other plugin developers as well? Please share them in the comments!


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *