Skip to content

Commit

Permalink
Squashed 'deploy-git-wordpress-org/' changes from cf3390e..66abbb4
Browse files Browse the repository at this point in the history
66abbb4 Tests for deploy tag method
68b3ce9 Test with readme worked
a964d3c Fix to issue not causing tag to get committed. Also updated verion.
b4b098b readme tweak
b4825a0 Reworked to allow the updating of only the readme.txt. Please only update to test

git-subtree-dir: deploy-git-wordpress-org
git-subtree-split: 66abbb4b74dde7e7ba77d19571b7f11457ca297d
  • Loading branch information
aubreypwd committed Jul 23, 2014
1 parent ab87586 commit f940d61
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 45 deletions.
131 changes: 94 additions & 37 deletions deploy-git-wordpress-org.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
#! /bin/bash

# deploy-git-wordpress-org.sh
# =================================================
# By: Aubrey Portwood
# https://github.com/aubreypwd/deploy-git-wordpress-org
# Version: 1.0
# =================================================
# Based on:
# https://github.com/brainstormmedia/deploy-plugin-to-wordpress-dot-org/blob/master/deploy.sh
# =================================================

# HEADERS MUST BE FORMATTED LIKE:
# =================================================
# /*
# Plugin Name: Google Destination URL
# Plugin URI: https://bitbucket.org/aubreypwd/gdurl
Expand All @@ -9,76 +20,122 @@
# Author: Aubrey Portwood
# Author URI: http://profiles.wordpress.org/aubreypwd/
# License: GPL2
# */
# */
#
# /** DOCBLOCKS DO NOT WORK!
# DOCBLOCKS DO NOT WORK!

# Based on:
# https://github.com/brainstormmedia/deploy-plugin-to-wordpress-dot-org/blob/master/deploy.sh
# =========================================================

echo "<deploy-git-wordpress-org>"
echo "=================================="

# Current directory
PLUGINSLUG=${PWD##*/}
CURRENTDIR=`pwd`
SVNIGNORE="deploy-git-wordpress-org
README.md
readme.md
.hg
.hgcheck
.hgignore
.git
.gitignore"

echo "- We will be ignoring some files in your Git repo:"
echo $SVNIGNORE

# Deps
if [ -z "$1" ] || [ -z "$2" ]; then
echo "Usage: sh deploy.wordpress.org.sh [plugin_file_with_header.php] [WordPress.org Username]";
if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]; then
echo "Usage: sh deploy.wordpress.org.sh [plugin_file_with_header.php] [WordPress.org Username] [Update Readme Only: true|false]";
echo "I.e.: sh deploy.wordpress.org.sh index.php aubreypwd false";
exit 1;
fi

# Temp place to put the SVN
SVNPATH="/tmp/$PLUGINSLUG"
SVNURL="http://plugins.svn.wordpress.org/$PLUGINSLUG"
SVNURL="http://plugins.svn.wordpress.org/$PLUGINSLUG"

echo "- Checking to make sure that your plugin and the stable tag in readme.txt are the same..."

# readme.txt Checks
NEWVERSION1=`grep "^Stable tag" $CURRENTDIR/readme.txt | awk -F' ' '{print $3}' | sed 's/[[:space:]]//g'`

echo "readme.txt Version: $NEWVERSION1"
echo "- readme.txt Version: $NEWVERSION1"

NEWVERSION2=`grep "^Version" $CURRENTDIR/$1 | awk -F' ' '{print $2}' | sed 's/[[:space:]]//g'`

echo "$1 Version: $NEWVERSION2"

# Exit if they don't match
if [ "$NEWVERSION1" != "$NEWVERSION2" ]; then echo "Versions don't match, sorry. Try again."; exit 1; fi
echo "- $1 Version: $NEWVERSION2"

# Commit Message
echo "SVN Commit Message: \c"
echo "- SVN Commit Message: \c"
read COMMITMSG

# SVN Work
svn co $SVNURL $SVNPATH
echo "- Just made a temporary copy of your SVN repo to $SVNPATH"

LANG1="- Just copied your Git repo to our temporary clone of your svn repo to $SVNPATH/trunk"
LANG2="- Committing your changes to WP.org..."

# Exit if they don't match
if [ "$NEWVERSION1" != "$NEWVERSION2" ]; then echo "- Versions don't match, sorry. Try again. Exiting...."; exit 1; fi

# Export master to SVN
git checkout-index -a -f --prefix=$SVNPATH/trunk/
# If readme $3 is true
if [ $3 = "true" ]; then

# Ignore some common files
svn propset svn:ignore "deploy-git-wordpress-org
README.md
readme.md
.hg
.hgcheck
.hgignore
.git
.gitignore" "$SVNPATH/trunk/"
echo "- You are just updating your readme.txt to the stable tag $SVNPATH/tags/$NEWVERSION2..."

# More SVN Work (commit)
cd $SVNPATH/trunk/
# Export master to SVN
git checkout-index -a -f --prefix=$SVNPATH/trunk/
echo "$LANG1"

# Addremove (YES!)
svn status | grep -v "^.[ \t]*\..*" | grep "^?" | awk '{print $2}' | xargs svn add
cd $SVNPATH/trunk/

# Commit the code
svn commit --username=$2 -m "$COMMITMSG"
# Ignore some common files
svn propset svn:ignore "$SVN_IGNORE" "$SVNPATH/trunk/"

# Copy the readme from trunk to the stable tag.
cp $SVNPATH/trunk/readme.txt $SVNPATH/tags/$NEWVERSION1/readme.txt
echo "- Just copied readme.txt from $SVNPATH/trunk/readme.txt to $SVNPATH/tags/$NEWVERSION1/readme.txt."

cd $SVNPATH/

echo "$LANG2"
svn commit --username=$2 -m "$COMMITMSG"

else

# Export master to SVN
git checkout-index -a -f --prefix=$SVNPATH/trunk/
echo "$LANG1"

# Ignore some common files
svn propset svn:ignore "$SVN_IGNORE" "$SVNPATH/trunk/"

# More SVN Work (commit)
cd $SVNPATH/trunk/

# Commit the tag
cd $SVNPATH
svn copy trunk/ tags/$NEWVERSION1/
cd $SVNPATH/tags/$NEWVERSION1
svn commit --username=$2 -m "Version/Tag: $NEWVERSION1"
# Addremove (YES!)
svn status | grep -v "^.[ \t]*\..*" | grep "^?" | awk '{print $2}' | xargs svn add
echo LANG1

# Commit the code
echo "$LANG2"
svn commit --username=$2 -m "$COMMITMSG"

# Commit the tag
cd $SVNPATH

echo "- Copying files from $SVNPATH/trunk to $SVNPATH/tags/$NEWVERSION2"
svn copy trunk/ tags/$NEWVERSION1/
cd $SVNPATH/tags/$NEWVERSION1

echo "- Comitting $NEWVERSION2 to WP.org..."
svn commit --username=$2 -m "Version/Tag: $NEWVERSION1"

fi

# Cleanup!
echo "- Removing the SVN repo at $SVNPATH"
rm -fr $SVNPATH/

cd $CURRENTDIR
cd $CURRENTDIR
24 changes: 16 additions & 8 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
# Avoid Errors
# Status

Always change the tag when using deploy to avoid adding `/trunk > /tags/{existing tag}/trunk`.
Current status of project is: **stable, ~~unstable~~, ~~untested~~, needs-community-testing**

# How to use
Things appear to be stable.

sh deploy.wordpress.org.sh [plugin_file_with_header.php] [WordPress.org Username]
- Tested the readme.txt update with success at https://plugins.trac.wordpress.org/changeset/851031 using true readme update switch.
- Tested the tag deploy method (old method) at http://plugins.trac.wordpress.org/changeset/851034 and http://plugins.trac.wordpress.org/changeset/851035

## Example
# How to use

sh deploy.wordpress.org.sh index.php aubreypwd
Usage: `sh deploy.wordpress.org.sh [plugin_file_with_header.php] [WordPress.org Username] [Update Readme Only: true|false]`
I.e.: `sh deploy.wordpress.org.sh index.php aubreypwd false`

## Add to your repo as a subtree

git subtree add --prefix deploy-git-wordpress-org https://github.com/aubreypwd/deploy-git-wordpress-org master --squash

## Periodically update (Updates your script from this repo)
## Update to the latest from the repository

git subtree pull --prefix deploy-git-wordpress-org https://github.com/aubreypwd/deploy-git-wordpress-org master --squash

Or use `sh deploy-git-wordpress-org/update-subtree.sh` once you've already added it.
Or, use `sh deploy-git-wordpress-org/update-subtree.sh` once you've already added it.

# Changelog

## 1.0

* Now accepts 3rd parameter that tells the script whether to just update the readme.txt or re-tag.

0 comments on commit f940d61

Please sign in to comment.