Writing plugins for yourself or others is a natural step for a developer that uses WordPress. Unfortunately if you want to share your plugins with the WordPress community that means submitting them to the WordPress plugin repository and there is one really sucky part about that – learning Subversion.
Subversion, or SVN, was great years ago when Git didn't exist. But since the emergence of GitHub, Git has become hugely popular and produces far fewer headaches than SVN. As a result new developers don't even bother learning SVN. Why learn to drive a stick shift when you can drive an automatic that has better gas mileage and more control?
With a lot of googling and several hacking sessions I took an existing shell script and modified it so that is does all of the cumbersome SVN for you. It will pull down the latest version of your Git repo, reproduce it in SVN, and push the changes to the WordPress plugin repository. It will even move your plugin assets (including the header image and screenshots) to the appropriate spot in the SVN repo.
Instructions
The new workflow using this deploy script is:
- Write awesome code
- Put the deployment script in the root of your repo
- Enter your WordPress username & location of your repo
- Deploy using a one line command in the terminal. ‘bash deploy.sh'
Does it require any knowledge of SVN? Nope. All you have to do is enter your WordPress.org credentials, your plugin name, and the location of your plugin repo. This script takes care of the rest.
If you want to include screenshots & a header image for the WordPress plugin repo you just have to put them into a assets-wp-repo directory at the root of your repo. Then the script will move them into the right location for you.
By the way, feel free to keep this deployment script in a public repo. There aren't any passwords saved and storing it in the repo it makes it far easier to deploy from any computer.
In the Wild
If you want to see a plugin that uses this script feel free to look at my JotForm Integration plugin in GitHub (with the deployment script) and in the WordPress Plugin Repository (with the assets saved in the right spot).
Credits
I, of course, did not do this all by myself – it's the Internet for God's sake. Brent Shepherd made some modifications on Dean Clatworthy's original script. Chris Schmitz and Jon Kinney helped me stumble through SVN.
Nice work Patrick. It’s great to see this script evolve!
Please also include Dean Clatworthy in the credits as I based my script on his. 🙂
Thanks Brent, I appreciate all the help you provided! I added Dean Clatworthy to the credits. 🙂
Hey Patrick! Really nice work – thanks for the script.
I am struggling to get my screenshots to show up in the WordPress Plugin Repository – to be honest I think they are never copied to $SVNPATH/assets.
Here’s the URL to my SVN repo: http://plugins.trac.wordpress.org/log/widget-title-links/ – as you can see, the screenshots are not in the /assets dir, they are only under the /trunk/assets and /tags/1.0/assets – but as far as I can understand from the plugin readme.txt instructions, they should still show up?
Hi @Illimar.
To answer your last question, no. You need to have the screenshots in the /assets/ directory. They can’t be in a subdirectory.
My suggestion would be for you to comment out the line with the
rm -fr $SVNPATH/
code, (currently line 86) so that when you’re running this script you can actually see where the files are being created. If you’re still having problems look at lines 62-66 as those are the lines that move the directory in the right place.Do you have a public GitHub that I can take a look at?
Good luck and let me know how it goes!
Thanks for the tip, @Patrick. I commented out that line and I can see that the local /assets directory contains my screenshots, but they do not appear in my plugin repo: http://plugins.trac.wordpress.org/browser/widget-title-links/assets
Can this have anything to do with the fact that I am not tagging a new release when I am deploying? I am just trying to get screenshots into the repository, so I do not want to create a new release each time I try to add a screenshot.
I always tagged a new release even when I just wanted to add a new screenshot (which is somewhat silly). I would give that a go and see if that fixes the issue.
I’m sure there’s a way to do it without tagging a new release, if you find it please let me know so I can update this script. 🙂
Good luck!
Congratulations !
I just used it to publish my plugin http://wordpress.org/extend/plugins/s2member-secure-file-browser/ and it works !
I’m happy to hear it! 🙂
[…] As part of my workflow I use GIT. It's awesome, easy to learn (hard to master) and just works. Sadly, the WordPress plugins repo uses SVN. So if you want to publish your plugin on the official repo, then you'll need to do some buggering about. Fortunately, Patrick Rauland has stepped up to the plate (with the assistance of others) and has produced a script which allows you to publish to the repo right from git (kinda). It's a simple one-minute setup process and then a one-line command. Pretty amazing. You can find it at A WordPress Plugin Deployment Shell Script […]
So can’t wait to use this. Updating the WP repo is my least favorite part of writing code! Just throwing this out there, but with git-svn commands is it possible to adjust the script to do away with SVN entirely?
I didn’t try using git-svn but it sure sounds possible. Since it’s all under the hood now it doesn’t bother me too much. 🙂
I tried everything out there and ended up having to write my own. Please give it a try @ https://github.com/axsuul/wp-plugin-deploy and let me know what you think 🙂