-
Notifications
You must be signed in to change notification settings - Fork 30
/
deploy.sh
executable file
·60 lines (49 loc) · 1.95 KB
/
deploy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# main config
CURRENTDIR=`pwd`
CURRENTVERSION=`cat version.txt`
MAINFILE="plugin-file-name.php" # this should be the name of your main php file in the wordpress plugin
# git config
GITPATH="/path/to/wordpress/wp-content/plugins/plugin-name/" # this should be the path to your git repository (trailing slash required)
# svn config
SVNPATH="/path/to/svn/repo/" # path to your checked out SVN repo. Trailing slash is required and don't add trunk.
SVNUSER="svnuser" # your svn username
# Let's begin...
echo ".........................................."
echo
echo "Preparing to deploy wordpress plugin"
echo "(Current version: $CURRENTVERSION)"
echo
echo ".........................................."
echo
# check version in readme.txt is the same as plugin file
NEWVERSION1=`grep "^Stable tag" $GITPATH/readme.txt | awk '{ print $NF}'`
echo $NEWVERSION1;
NEWVERSION2=`grep "^Version" $GITPATH/$MAINFILE | awk '{ print $NF}'`
echo $NEWVERSION2;
if [ "$NEWVERSION1" != "$NEWVERSION2" ]; then echo "Versions don't match. Exiting...."; exit 1; fi
echo "Versions match in readme.txt and PHP file. Let's proceed..."
# change into the git dir and get a commit message
cd $GITPATH
echo -e "Enter a commit message describing the changes made: \c"
read COMMITMSG
git commit -a -m "$COMMITMSG"
# push to origin
echo "Push latest commit to origin"
git push origin master
# Export git contents to svn directory
echo
echo "Exporting the HEAD of master from git to the trunk of SVN"
git checkout-index -a -f --prefix=$SVNPATH/trunk/
# Change to SVN dir and commit changes
echo "Changing directory to SVN and committing to trunk"
cd $SVNPATH/trunk
svn commit --username=$SVNUSER -m "$COMMITMSG"
# Create a new tag and commit it :)
echo "Creating new SVN tag"
cd $SVNPATH
svn copy trunk/ tags/$NEWVERSION1
svn commit --username=$SVNUSER -m "Updating tag to $NEWVERSION1"
# Update the version number
echo "Updating version number for future executions"
cd $CURRENTDIR
echo $NEWVERSION1 > version.txt