├── deploy-git-wordpress-org.sh └── readme.md /deploy-git-wordpress-org.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | # deploy-git-wordpress-org.sh 4 | 5 | # By: Aubrey Portwood, Brad Parbs 6 | # https://github.com/aubreypwd/deploy-git-wordpress-org 7 | # Version: 1.0 8 | # Based on: https://github.com/brainstormmedia/deploy-plugin-to-wordpress-dot-org/blob/master/deploy.sh 9 | 10 | # HEADERS MUST BE FORMATTED LIKE: 11 | # 12 | # /* 13 | # Plugin Name: Google Destination URL 14 | # Plugin URI: https://bitbucket.org/aubreypwd/gdurl 15 | # Description: Perform a Google Search when adding a link in the editor. 16 | # Version: 1.0 17 | # Author: Aubrey Portwood 18 | # Author URI: http://profiles.wordpress.org/aubreypwd/ 19 | # License: GPL2 20 | # */ 21 | # 22 | # DOCBLOCKS DO NOT WORK! 23 | 24 | # Deps 25 | if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]; then 26 | echo "Usage: sh deploy.wordpress.org.sh [plugin_file_with_header.php] [WordPress.org Username] [Update Readme Only: true|false]"; 27 | echo "I.e.: sh deploy.wordpress.org.sh index.php aubreypwd false"; 28 | exit 1; 29 | fi 30 | 31 | echo "Starting Deployment to WP.org..." 32 | echo "================================" 33 | 34 | # Current directory 35 | PLUGINSLUG=${PWD##*/} 36 | CURRENTDIR=$(pwd) 37 | SVNIGNORE="deploy-git-wordpress-org 38 | README.md 39 | readme.md 40 | .hg 41 | .hgcheck 42 | .hgignore 43 | .git 44 | .gitignore" 45 | 46 | # Temp place to put the SVN 47 | SVNPATH="/tmp/$PLUGINSLUG" 48 | SVNURL="http://plugins.svn.wordpress.org/$PLUGINSLUG" 49 | 50 | echo "- Checking to make sure that your plugin and the stable tag in readme.txt are the same..." 51 | 52 | # readme.txt Checks 53 | NEWVERSION1=$(grep "^Stable tag" "$CURRENTDIR"/readme.txt | awk -F' ' '{print $3}' | sed 's/[[:space:]]//g') 54 | 55 | echo "- readme.txt Version: $NEWVERSION1" 56 | 57 | NEWVERSION2=$(grep "^Version" "$CURRENTDIR"/"$1" | awk -F' ' '{print $2}' | sed 's/[[:space:]]//g') 58 | 59 | echo "- $1 Version: $NEWVERSION2" 60 | 61 | # Commit Message 62 | echo "- SVN Commit Message: \c" 63 | read COMMITMSG 64 | 65 | # SVN Work 66 | svn co "$SVNURL" "$SVNPATH" 67 | echo "- Just made a temporary copy of your SVN repo to $SVNPATH" 68 | 69 | LANG1="- Just copied your Git repo to our temporary clone of your svn repo to $SVNPATH/trunk" 70 | LANG2="- Committing your changes to WP.org..." 71 | 72 | # Exit if they don't match 73 | if [ "$NEWVERSION1" != "$NEWVERSION2" ]; then echo "- Versions don't match, sorry. Try again. Exiting...."; exit 1; fi 74 | 75 | # If readme $3 is true 76 | if [ "$3" = "true" ]; then 77 | 78 | echo "- You are just updating your readme.txt to the stable tag $SVNPATH/tags/$NEWVERSION2..." 79 | 80 | # Export master to SVN 81 | git checkout-index -a -f --prefix="$SVNPATH"/trunk/ 82 | echo "$LANG1" 83 | 84 | cd "$SVNPATH"/trunk/ 85 | 86 | # Ignore some common files 87 | svn propset svn:ignore "$SVNIGNORE" "$SVNPATH/trunk/" 88 | 89 | # Copy the readme from trunk to the stable tag. 90 | cp "$SVNPATH"/trunk/readme.txt "$SVNPATH"/tags/"$NEWVERSION1"/readme.txt 91 | echo "- Just copied readme.txt from $SVNPATH/trunk/readme.txt to $SVNPATH/tags/$NEWVERSION1/readme.txt." 92 | 93 | cd "$SVNPATH" 94 | 95 | echo "$LANG2" 96 | svn commit --username="$2" -m "$COMMITMSG" 97 | 98 | else 99 | 100 | # Export master to SVN 101 | git checkout-index -a -f --prefix="$SVNPATH"/trunk/ 102 | echo "$LANG1" 103 | 104 | # Ignore some common files 105 | svn propset svn:ignore "$SVNIGNORE" "$SVNPATH/trunk/" 106 | 107 | # More SVN Work (commit) 108 | cd "$SVNPATH"/trunk 109 | 110 | # Addremove (YES!) 111 | svn status | grep -v "^.[ \t]*\..*" | grep "^?" | awk '{print $2}' | xargs svn add 112 | echo LANG1 113 | 114 | # Commit the code 115 | echo "$LANG2" 116 | svn commit --username="$2" -m "$COMMITMSG" 117 | 118 | # Commit the tag 119 | cd "$SVNPATH" 120 | 121 | echo "- Copying files from $SVNPATH/trunk to $SVNPATH/tags/$NEWVERSION2" 122 | svn copy trunk/ tags/"$NEWVERSION1"/ 123 | cd "$SVNPATH"/tags/"$NEWVERSION1" 124 | 125 | echo "- Committing $NEWVERSION2 to WP.org..." 126 | svn commit --username="$2" -m "Version/Tag: $NEWVERSION1" 127 | 128 | fi 129 | 130 | # Cleanup! 131 | echo "- Removing the SVN repo at $SVNPATH" 132 | rm -rf "${SVNPATH:?}/"* 133 | 134 | echo "Deployment finished." -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # Usage 2 | 3 | Usage: `sh deploy.wordpress.org.sh [plugin_file_with_header.php] [WordPress.org Username] [Update Readme Only: true|false]` 4 | I.e.: `sh deploy.wordpress.org.sh index.php aubreypwd false` 5 | 6 | # Download Script 7 | 8 | *(Right Click & Save As)* 9 | 10 | - [Download Stable v1.0](https://raw.githubusercontent.com/aubreypwd/deploy-git-wordpress-org/1.0-summit/deploy-git-wordpress-org.sh) 11 | - [Download In-Development v1.1-dev](https://raw.githubusercontent.com/aubreypwd/deploy-git-wordpress-org/master/deploy-git-wordpress-org.sh) 12 | 13 | *Note that the in-development version may be unstable.* 14 | 15 | # Add to your project 16 | 17 | *Replace `1.0-summit` below with `master` for the in-development version.* 18 | 19 | ## Add as a Subtree 20 | 21 | git subtree add --prefix deploy-git-wordpress-org https://github.com/aubreypwd/deploy-git-wordpress-org 1.0-summit --squash 22 | 23 | ### Update to the latest from the repository 24 | 25 | git subtree pull --prefix deploy-git-wordpress-org https://github.com/aubreypwd/deploy-git-wordpress-org 1.0-summit --squash 26 | 27 | ## As as Submodule 28 | 29 | git submodule add -b 1.0-summit https://github.com/aubreypwd/deploy-git-wordpress-org 30 | 31 | _______________________ 32 | 33 | # Changelog 34 | 35 | ## 1.0 "Summit" 36 | 37 | - Now accepts 3rd parameter that tells the script whether to just update the readme.txt or re-tag. 38 | 39 | ## 1.1 (In Development) 40 | 41 | - Improvements to Shell Script thanks to @bradp 42 | - Changes and re-wording of some of the output --------------------------------------------------------------------------------