Skip to content

Instantly share code, notes, and snippets.

@jaredatch
Created April 17, 2015 14:09
Show Gist options
  • Save jaredatch/9d3441d76cb5aeb01e71 to your computer and use it in GitHub Desktop.
Save jaredatch/9d3441d76cb5aeb01e71 to your computer and use it in GitHub Desktop.
Simple WP.org git deploy. No frills, no tags, no BS.
#! /bin/bash
# main config
PLUGINSLUG=${PWD##*/} # returns basename of current directory
CURRENTDIR=`pwd`
# configs
GITPATH="$CURRENTDIR/" # this file should be in the base of your git repository
SVNPATH="/tmp/$PLUGINSLUG" # path to a temp SVN repo. No trailing slash required and don't add trunk.
SVNURL="http://plugins.svn.wordpress.org/$PLUGINSLUG" # Remote SVN repo on wordpress.org, with no trailing slash
SVNUSER="jaredatch" # your svn username
# Let's begin...
echo
echo "Preparing to deploy WordPress plugin..."
echo
cd $GITPATH
echo -e "Enter a commit message for this new version: \c"
read COMMITMSG
echo "Creating local copy of SVN repo ..."
svn co $SVNURL $SVNPATH
echo "Exporting the HEAD of master from git to the trunk of SVN"
git checkout-index -a -f --prefix=$SVNPATH/trunk/
echo "Ignoring github specific files and deployment script"
svn propset svn:ignore "deploy.sh
README.md
.DS_Store
.git
.gitignore" "$SVNPATH/trunk/"
echo "Changing directory to SVN and committing to trunk"
cd $SVNPATH/trunk/
# Add all new files that are not set to be ignored
svn status | grep -v "^.[ \t]*\..*" | grep "^?" | awk '{print $2}' | xargs svn add
svn commit --username=$SVNUSER -m "$COMMITMSG"
echo "Removing temporary directory $SVNPATH"
rm -fr $SVNPATH/
echo "*** Done! ***"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment