Skip to content
This repository was archived by the owner on May 10, 2023. It is now read-only.

Commit 771b43e

Browse files
committed
Initial commit
1 parent ce6a715 commit 771b43e

File tree

2 files changed

+143
-0
lines changed

2 files changed

+143
-0
lines changed

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Github to WordPress Plugin Directory Deployment Script, Git-Flow Version
2+
3+
Deploys a WordPress plugin from Github (git) to the WordPress Plugin Repostiory (svn), taking account of standard [git-flow](https://github.com/nvie/gitflow) usage.
4+
5+
## Credits
6+
Well over 90% of this script was written by others:
7+
8+
- **[Dean Clatworthy](https://twitter.com/deanclatworthy)** - [Original script](https://github.com/deanc/wordpress-plugin-git-svn)
9+
- **[Brent Shepherd](https://twitter.com/thenbrent)** - [Avoids permanent local SVN repo, avoids sending redundant stuff to WP repo](http://thereforei.am/2011/04/21/git-to-svn-automated-wordpress-plugin-deployment/)
10+
- **[Patrick Rauland](https://twitter.com/BFTrick)** - [Support for WP assets folder for plugin page banner and screenshots](https://github.com/BFTrick/jotform-integration/blob/master/deploy.sh)
11+
- **[Ben Balter](https://twitter.com/benbalter)** - [Submodules support and plugin slug prompt](https://github.com/benbalter/Github-to-WordPress-Plugin-Directory-Deployment-Script/)
12+
- **[Gary Jones](https://twitter.com/GaryJ)** *(me)* - [Personalisation and commenting out bits not required when using git-flow](https://github.com/GaryJones/wordpress-plugin-git-flow-svn-deploy)
13+
14+
## Process
15+
1. Prompts for plugin slug.
16+
- Verifies plugin header version number matches readme stable version number.
17+
- Pushes latest git commit and tags to GitHub.
18+
- Creates temporary checkout of SVN repo.
19+
- Ignores non-WordPress repo files from SVN.
20+
- Copies git export to SVN trunk.
21+
- Checks out any submodules.
22+
- Copies contents of assets directory in trunk to a directory parallel to trunk.
23+
- Commits SVN trunk, assets and tag.
24+
- Attempts to remove temporary SVN checkout.
25+
26+
## Usage
27+
With [git-flow](https://github.com/nvie/gitflow), specifically the `git flow release finish ...` command, the release branch is merged into the develop branch, the master branch and a tag is created, so these aren't needed with this deploy script.
28+
29+
I prefer to keep this script in the root of my projects directory. Each project directory is named as the plugin slug, as is the corresponding GitHub repo. To use, just call the script, enter the plugin slug, and sit back as the code is sent to SVN and git repos including tags. The commit messages here are hard-coded for consistency.
30+
31+
32+

deploy.sh

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
#! /bin/bash
2+
# See https://github.com/GaryJones/wordpress-plugin-git-flow-svn-deploy for instructions and credits.
3+
4+
echo -e "Plugin Slug: \c"
5+
read PLUGINSLUG
6+
7+
# main config
8+
CURRENTDIR=`pwd`
9+
PLUGINDIR="$CURRENTDIR/$PLUGINSLUG"
10+
MAINFILE="$PLUGINSLUG.php" # this should be the name of your main PHP file in the WordPress plugin
11+
12+
# git config
13+
GITPATH="$PLUGINDIR/" # this file should be in the base of your git repository
14+
15+
# svn config
16+
SVNPATH="/tmp/$PLUGINSLUG" # path to a temp SVN repo. No trailing slash required and don't add trunk.
17+
SVNURL="http://plugins.svn.wordpress.org/$PLUGINSLUG" # Remote SVN repo on WordPress.org, with no trailing slash
18+
SVNUSER="GaryJ" # your svn username
19+
20+
# Let's begin...
21+
echo ".........................................."
22+
echo
23+
echo "Preparing to deploy WordPress plugin"
24+
echo
25+
echo ".........................................."
26+
echo
27+
28+
# Check version in readme.txt is the same as plugin file after translating both to unix line breaks to work around grep's failure to identify mac line breaks
29+
NEWVERSION1=`grep "^Stable tag:" $GITPATH/readme.txt | awk -F' ' '{print $NF}'`
30+
echo "readme.txt version: $NEWVERSION1"
31+
NEWVERSION2=`grep "Version:" $GITPATH/$MAINFILE | awk -F' ' '{print $NF}'`
32+
echo "$MAINFILE version: $NEWVERSION2"
33+
34+
if [ "$NEWVERSION1" != "$NEWVERSION2" ]; then echo "Version in readme.txt & $MAINFILE don't match. Exiting...."; exit 1; fi
35+
36+
echo "Versions match in readme.txt and $MAINFILE. Let's proceed..."
37+
38+
# GaryJ: Ignore check for git tag, as git flow release finish creates this.
39+
#if git show-ref --tags --quiet --verify -- "refs/tags/$NEWVERSION1"
40+
# then
41+
# echo "Version $NEWVERSION1 already exists as git tag. Exiting....";
42+
# exit 1;
43+
# else
44+
# echo "Git version does not exist. Let's proceed..."
45+
#fi
46+
47+
echo "Changing to $GITPATH"
48+
cd $GITPATH
49+
# GaryJ: Commit message variable not needed . Hard coded for SVN trunk commit for consistency.
50+
#echo -e "Enter a commit message for this new version: \c"
51+
#read COMMITMSG
52+
# GaryJ: git flow release finish already covers this commit.
53+
#git commit -am "$COMMITMSG"
54+
55+
# GaryJ: git flow release finish already covers this tag creation.
56+
#echo "Tagging new version in git"
57+
#git tag -a "$NEWVERSION1" -m "Tagging version $NEWVERSION1"
58+
59+
echo "Pushing git master to origin, with tags"
60+
git push origin master
61+
git push origin master --tags
62+
63+
echo
64+
echo "Creating local copy of SVN repo ..."
65+
svn co $SVNURL $SVNPATH
66+
67+
echo "Ignoring GitHub specific files"
68+
svn propset svn:ignore "README.md
69+
Thumbs.db
70+
.git
71+
.gitignore" "$SVNPATH/trunk/"
72+
73+
echo "Exporting the HEAD of master from git to the trunk of SVN"
74+
git checkout-index -a -f --prefix=$SVNPATH/trunk/
75+
76+
# If submodule exist, recursively check out their indexes
77+
if [ -f ".gitmodules" ]
78+
then
79+
echo "Exporting the HEAD of each submodule from git to the trunk of SVN"
80+
git submodule init
81+
git submodule update
82+
git submodule foreach --recursive 'git checkout-index -a -f --prefix=$SVNPATH/trunk/$path/'
83+
fi
84+
85+
# Support for the /assets folder on the .org repo.
86+
echo "Moving assets"
87+
mkdir $SVNPATH/assets/
88+
mv $SVNPATH/trunk/assets/* $SVNPATH/assets/
89+
svn add $SVNPATH/assets/
90+
svn delete $SVNPATH/trunk/assets
91+
92+
echo "Changing directory to SVN and committing to trunk"
93+
cd $SVNPATH/trunk/
94+
# Add all new files that are not set to be ignored
95+
svn status | grep -v "^.[ \t]*\..*" | grep "^?" | awk '{print $2}' | xargs svn add
96+
svn commit --username=$SVNUSER -m "Preparing for $NEWVERSION1 release"
97+
98+
echo "Updating WordPress plugin repo assets and committing"
99+
cd $SVNPATH/assets/
100+
svn commit --username=$SVNUSER -m "Updating assets"
101+
102+
echo "Creating new SVN tag and committing it"
103+
cd $SVNPATH
104+
svn copy trunk/ tags/$NEWVERSION1/
105+
cd $SVNPATH/tags/$NEWVERSION1
106+
svn commit --username=$SVNUSER -m "Tagging version $NEWVERSION1"
107+
108+
echo "Removing temporary directory $SVNPATH"
109+
rm -fr $SVNPATH/
110+
111+
echo "*** FIN ***"

0 commit comments

Comments
 (0)