Skip to content

Instantly share code, notes, and snippets.

@samargulies
Created October 26, 2011 17:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samargulies/1317096 to your computer and use it in GitHub Desktop.
Save samargulies/1317096 to your computer and use it in GitHub Desktop.
Bash script to deploy a WordPress plugin git repository to the plugin directory
#! /bin/bash
# Update a WordPress plugin from git
# Based on scripts from thenbrent (https://github.com/thenbrent/multisite-user-management/blob/master/deploy.sh) and scribu (https://gist.github.com/1125050)
# main config
SRC_DIR=$(pwd)
DIR_NAME=$(basename "$SRC_DIR")
SVNUSER="gluten"
SVNPATH="/tmp/$DIR_NAME"
SVNURL="http://plugins.svn.wordpress.org/$DIR_NAME/"
# make sure we're deploying from the right dir
if [ ! -d "$SRC_DIR/.git" ]; then
echo "$SRC_DIR doesn't seem to be a git repository"
exit
fi
# Get the version number
NEWVERSION=`grep "^Stable tag" "$SRC_DIR/readme.txt" | awk '{print $NF}'`
read -p "Ready to deploy $DIR_NAME to version $NEWVERSION. Press any key to continue ..."
cd "$SRC_DIR"
echo "Creating local copy of SVN repo ..."
svn co $SVNURL $SVNPATH
git checkout-index -a -f --prefix=$SVNPATH/trunk/
svn propset svn:ignore "README.md
.git
.gitignore" "$SVNPATH/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
cd $SVNPATH
svn copy trunk tags/$NEWVERSION
echo "Committing changes to svn ..."
svn status
svn commit --username=$SVNUSER -m "Update to version $NEWVERSION"
echo "Removing temporary directory $SVNPATH"
rm -rf $SVNPATH/
echo "Plugin deploy complete."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment