If you’ve built plugins you’ve undoubtedly spent a whole lot of time and energy finishing up on sweet new feature X only to then face the hurdle of having to prep the whole shebang for release.
I was tired of hitting that final hurdle whilst working on the ACF Custom Database Tables plugin so I decided to do something clever – I automated stuff.
At first, I had a bash script that was doing all the goods for me. It was basically just a command that had the plugin’s directory and various details hard-coded into it. It was decent and saved me time but kinda fell on its face when I moved the dev installation to another directory and forgot about the command…
At that point, I was like “Dafuq am I doing? Why aren’t I using WP CLI?!”
So that’s where I took it next and I’m so glad I did! It’s been super-duper handy and the release process is now super-duper dandy as I no longer have to think hard or work through a checklist in order to make a release-ready archive of a plugin. All I need to do is run
wp makerelease on the command line and an archive will be prepared in the
wp-content/releases directory with the plugin version in the filename.
There isn’t a lot. You either define a custom suffix or you don’t.
rsyncto create a copy of the plugin dir.
The following class is an invokable class the represents one command. You can customise the command along with the file exclusions and a few other bits by modifying the class constants.
FYI, this particular example is namespaced to a project I’m working on so you should change that to suit your own plugin.
I just include this in my
wp-config.php file and register it with WP CLI using the following:
If you liked this article, I'd be incredibly grateful if you tweeted about it.
Also, I don't send emails often but when I do, I try to fill them full of useful goodies. If you like code snippets & dev tips, join my mailing list. There's no catch but I'll probably want to tell you about any new plugins & tools I build.