WPsites Home
WordPress : state-of-the-art content management system Login to your account

Git to SVN deploy script for easily publishing your WordPress plugins to WordPress.org

git-github-svn-wordpress

Git is my version control system of choice and SVN just feels like a step backwards. Consequently I’m using Github to store the source code of my WordPress plugins making it super easy for anyone to fork/contribute.

For months I’ve been searching for an easier way to publish my code on Github to the WordPress.org repository without typing in SVN commands and finally I’ve found it.

I just wanted to point out that Git is my primary version control system and the wordpress.org svn repository is used only as a distribution mechanism. As far as I’m concerned I never want to type another SVN command, if SVN must be used then I would rather automate that whole side of things.

There is an interesting blog post that goes over the differences between using Git as your primary or secondary version control system and also documents a non automated way of keeping your GIt and SVN repositories in sync (even the commit history).

By this time you probably just want to see the deployment script…

The wporg-deploy.sh script can be viewed over on the Github repository for WPide, a plugin I’m actively developing (a WordPress code editor).

The script is simple to configure with just a few variables towards the top of the script that you will need to update with your own info:

# main config
PLUGINSLUG="wpide" # this is used to create the tmp directory so don't use spaces etc
MAINFILE="WPide.php" # this should be the name of your main php file in the wordpress plugin

# svn config
SVNURL="http://plugins.svn.wordpress.org/wpide/" # URL to the remote SVN repo on wordpress.org, with no trailing slash
SVNUSER="WPsites" # your svn username
SVNIGNORE="
backups
.DS_Store" #other files you you don't need to publish to the WP.org repo

Once you have a copy of the deployment script in the root of your plugin (in your git repo), that you’ve configured with your details, you can publish your plugin to the WordPress SVN repo just by executing the wporg-deply.sh script.

Your workflow then goes like this:

1) You make changes to your plugin in your local Git repository

2) Once those changes are ready for release (on the master branch of your local repo) make your final commit to update the version tags in your readme.txt file + main plugin file and update the changelog in the readme.txt file

3) Final step is to execute the ./wporg-deploy.sh script to publish the plugin to the WordPress repo over SVN

The script takes care of tagging the release on your local Git repo, pushing that tag to your origin (Github in most cases) as well as tagging the release on the WordPress SVN repo and uploading everything.

That’s it, you use Git as your version control system and you run the script to publish the plugin to the WordPress plugin directory, no more SVN commands!

I didn’t write this script. I found it on Github https://github.com/thenbrent/multisite-user-management/blob/master/deploy.sh after months of looking for an easier way to publish my plugins to the WordPress SVN repo.