|
| 1 | +#! /bin/bash |
| 2 | +# A modification of Dean Clatworthy's deploy script as found here: https://github.com/deanc/wordpress-plugin-git-svn |
| 3 | +# The difference is that this script lives in the plugin's git repo & doesn't require an existing SVN repo. |
| 4 | + |
| 5 | +# main config |
| 6 | +PLUGINSLUG="nginx-helper" |
| 7 | +MAINFILE="nginx-helper.php" # this should be the name of your main php file in the wordpress plugin |
| 8 | +#SVNUSER="rtcamp" # your svn username |
| 9 | + |
| 10 | + |
| 11 | +##### YOU CAN STOP EDITING HERE ##### |
| 12 | +CURRENTDIR=`pwd` |
| 13 | + |
| 14 | +# git config |
| 15 | +GITPATH="$CURRENTDIR/" # this file should be in the base of your git repository |
| 16 | + |
| 17 | +# svn config |
| 18 | +SVNPATH="/tmp/$PLUGINSLUG" # path to a temp SVN repo. No trailing slash required and don't add trunk. |
| 19 | +SVNURL="https://plugins.svn.wordpress.org/$PLUGINSLUG/" # Remote SVN repo on wordpress.org, with no trailing slash |
| 20 | + |
| 21 | +# Detect svn username based on url |
| 22 | +SVNUSER=$(cat ~/.subversion/auth/svn.simple/* | grep -A4 $(echo $SVNURL | awk -F// '{print $2}' | cut -d'/' -f1) | tail -n1) |
| 23 | +if [ -z "$SVNUSER" ] |
| 24 | +then |
| 25 | + SVNUSER="chandrapatel" |
| 26 | +fi |
| 27 | + |
| 28 | + |
| 29 | +# Let's begin... |
| 30 | +echo ".........................................." |
| 31 | +echo |
| 32 | +echo "Preparing to deploy WordPress plugin" |
| 33 | +echo |
| 34 | +echo ".........................................." |
| 35 | +echo |
| 36 | + |
| 37 | +# Check version in readme.txt is the same as plugin file |
| 38 | +NEWVERSION1=`grep "^Stable tag" $GITPATH/readme.txt | awk -F' ' '{print $3}'` |
| 39 | +echo "readme version: $NEWVERSION1" |
| 40 | +#NEWVERSION2=`grep "^Version" $GITPATH/$MAINFILE | awk -F' ' '{print $2}'` |
| 41 | +NEWVERSION2=`grep -i "Version" $GITPATH/$MAINFILE | head -n1 | awk -F':' '{print $2}' | awk -F' ' '{print $1}'` |
| 42 | +echo "$MAINFILE version: $NEWVERSION2" |
| 43 | + |
| 44 | +if [ "$NEWVERSION1" != "$NEWVERSION2" ]; then echo "Versions don't match. Exiting...."; exit 1; fi |
| 45 | + |
| 46 | +echo "Versions match in readme.txt and PHP file. Let's proceed..." |
| 47 | + |
| 48 | +cd $GITPATH |
| 49 | +bash readme.sh $SVNURL |
| 50 | +git add README.md |
| 51 | +echo -e "Enter a commit message for this new version: \c" |
| 52 | +read COMMITMSG |
| 53 | +git commit -am "$COMMITMSG" |
| 54 | + |
| 55 | +echo "Tagging new version in git" |
| 56 | +git tag -a "$NEWVERSION1" -m "Tagging version $NEWVERSION1" |
| 57 | + |
| 58 | +echo "Pushing latest commit to origin, with tags" |
| 59 | +git push origin master |
| 60 | +git push origin master --tags |
| 61 | + |
| 62 | +echo |
| 63 | +echo "Creating local copy of SVN repo ..." |
| 64 | +svn co $SVNURL $SVNPATH |
| 65 | + |
| 66 | +echo "Exporting the HEAD of master from git to the trunk of SVN" |
| 67 | +git checkout-index -a -f --prefix=$SVNPATH/trunk/ |
| 68 | + |
| 69 | +echo "Ignoring github specific files and deployment script" |
| 70 | +svn propset svn:ignore "deploy.sh |
| 71 | +readme.sh |
| 72 | +README.md |
| 73 | +.git |
| 74 | +.gitattributes |
| 75 | +.gitignore |
| 76 | +tests |
| 77 | +map.conf |
| 78 | +nginx.log" "$SVNPATH/trunk/" |
| 79 | + |
| 80 | +echo "Changing directory to SVN and committing to trunk" |
| 81 | +cd $SVNPATH/trunk/ |
| 82 | +# Add all new files that are not set to be ignored |
| 83 | +svn status | grep -v "^.[ \t]*\..*" | grep "^?" | awk '{print $2}' | xargs svn add |
| 84 | +svn commit --username=$SVNUSER -m "$COMMITMSG" |
| 85 | + |
| 86 | +echo "Creating new SVN tag & committing it" |
| 87 | +cd $SVNPATH |
| 88 | +svn copy trunk/ tags/$NEWVERSION1/ |
| 89 | +cd $SVNPATH/tags/$NEWVERSION1 |
| 90 | +svn commit --username=$SVNUSER -m "Tagging version $NEWVERSION1" |
| 91 | + |
| 92 | +echo "Removing temporary directory $SVNPATH" |
| 93 | +rm -fr $SVNPATH/ |
| 94 | + |
| 95 | +echo "*** FIN ***" |
0 commit comments