From f8c7874a785c3f36985cba6e007cddd3ea90e242 Mon Sep 17 00:00:00 2001 From: Jakub Niewiarowski Date: Sat, 25 Jul 2015 02:17:10 +0200 Subject: [PATCH] deployment bootstrap. --- deploy-common.sh | 90 +++++++++++++++++++++++++++++++++++++++++++++ deploy.sh | 94 +++++++++++++++++++++++++++++++++++++++++++++++ readme.sh | 96 ++++++++++++++++++++++++++++++++++++++++++++++++ readme.txt | 4 +- 4 files changed, 282 insertions(+), 2 deletions(-) create mode 100644 deploy-common.sh create mode 100755 deploy.sh create mode 100644 readme.sh diff --git a/deploy-common.sh b/deploy-common.sh new file mode 100644 index 0000000..825631f --- /dev/null +++ b/deploy-common.sh @@ -0,0 +1,90 @@ +##### YOU CAN STOP EDITING HERE ##### +CURRENTDIR=`pwd` + +# git config +GITPATH="$CURRENTDIR/" # this file should be in the base of your git repository + +# svn config +SVNPATH="/tmp/$PLUGINSLUG" # path to a temp SVN repo. No trailing slash required and don't add trunk. +SVNURL="https://plugins.svn.wordpress.org/$PLUGINSLUG/" # Remote SVN repo on wordpress.org, with no trailing slash + +# Detect svn username based on url +SVNUSER=$(cat ~/.subversion/auth/svn.simple/* | grep -A4 $(echo $SVNURL | awk -F// '{print $2}' | cut -d'/' -f1) | tail -n1) +if [ -z "$SVNUSER" ] +then + SVNUSER="rtcamp" +fi + + +# Let's begin... +echo ".........................................." +echo +echo "Preparing to deploy wordpress plugin" +echo +echo ".........................................." +echo + +# Check version in readme.txt is the same as plugin file +NEWVERSION1=`grep "^Stable tag" $GITPATH/readme.txt | awk -F' ' '{print $3}'` +echo "readme version: $NEWVERSION1" +#NEWVERSION2=`grep "^Version" $GITPATH/$MAINFILE | awk -F' ' '{print $2}'` +NEWVERSION2=`grep -i "Version" $GITPATH/$MAINFILE | head -n1 | awk -F':' '{print $2}' | awk -F' ' '{print $1}'` +echo "$MAINFILE version: $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..." + +cd $GITPATH +wget https://raw.github.com/rtCamp/wp-plugin-bootstrap/master/readme.sh +bash readme.sh $SVNURL +rm readme.sh +echo -e "Enter a commit message for this new version: \c" +read COMMITMSG +git commit -am "$COMMITMSG" + +echo "Tagging new version in git" +git tag -a "$NEWVERSION1" -m "Tagging version $NEWVERSION1" + +echo "Pushing latest commit to origin, with tags" +git push origin master +git push origin master --tags + +echo +echo "Creating local copy of SVN repo ..." +svn co $SVNURL $SVNPATH + +echo "Exporting the HEAD of master from git to the trunk of SVN" +git checkout-index -a -f --prefix=$SVNPATH/trunk/ + +echo "Ignoring github specific files and deployment script" +svn propset svn:ignore "deploy.sh +deploy-common.sh +readme.sh +README.md +.git +.gitattributes +.gitignore +map.conf +nginx.log +tests +bin +assets +phpunit.xml" "$SVNPATH/trunk/" + +echo "Changing directory to SVN and committing to trunk" +cd $SVNPATH/trunk/ +# Add all new files that are not set to be ignored +svn status | grep -v "^.[ \t]*\..*" | grep "^?" | awk '{print $2}' | xargs svn add +svn commit --username=$SVNUSER -m "$COMMITMSG" + +echo "Creating new SVN tag & committing it" +cd $SVNPATH +svn copy trunk/ tags/$NEWVERSION1/ +cd $SVNPATH/tags/$NEWVERSION1 +svn commit --username=$SVNUSER -m "Tagging version $NEWVERSION1" + +echo "Removing temporary directory $SVNPATH" +rm -fr $SVNPATH/ + +echo "*** FIN ***" diff --git a/deploy.sh b/deploy.sh new file mode 100755 index 0000000..7f39e41 --- /dev/null +++ b/deploy.sh @@ -0,0 +1,94 @@ +#! /bin/bash +# A modification of Dean Clatworthy's deploy script as found here: https://github.com/deanc/wordpress-plugin-git-svn +# The difference is that this script lives in the plugin's git repo & doesn't require an existing SVN repo. + +# main config +PLUGINSLUG="query-filter" #must match with wordpress.org plugin slug +MAINFILE="j-query-filter.php" # this should be the name of your main php file in the wordpress plugin +#SVNUSER="rtcamp" # your svn username + + +##### YOU CAN STOP EDITING HERE ##### +CURRENTDIR=`pwd` + +# git config +GITPATH="$CURRENTDIR/" # this file should be in the base of your git repository + +# svn config +SVNPATH="/tmp/$PLUGINSLUG" # path to a temp SVN repo. No trailing slash required and don't add trunk. +SVNURL="https://plugins.svn.wordpress.org/$PLUGINSLUG/" # Remote SVN repo on wordpress.org, with no trailing slash + +# Detect svn username based on url +SVNUSER=$(cat ~/.subversion/auth/svn.simple/* | grep -A4 $(echo $SVNURL | awk -F// '{print $2}' | cut -d'/' -f1) | tail -n1) +if [ -z "$SVNUSER" ] +then + SVNUSER="rtcamp" +fi + + +# Let's begin... +echo ".........................................." +echo +echo "Preparing to deploy wordpress plugin" +echo +echo ".........................................." +echo + +# Check version in readme.txt is the same as plugin file +NEWVERSION1=`grep "^Stable tag" $GITPATH/readme.txt | awk -F' ' '{print $3}'` +echo "readme version: $NEWVERSION1" +#NEWVERSION2=`grep "^Version" $GITPATH/$MAINFILE | awk -F' ' '{print $2}'` +NEWVERSION2=`grep -i "Version" $GITPATH/$MAINFILE | head -n1 | awk -F':' '{print $2}' | awk -F' ' '{print $1}'` +echo "$MAINFILE version: $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..." + +cd $GITPATH +bash readme.sh $SVNURL +git add README.md +echo -e "Enter a commit message for this new version: \c" +read COMMITMSG +git commit -am "$COMMITMSG" + +echo "Tagging new version in git" +git tag -a "$NEWVERSION1" -m "Tagging version $NEWVERSION1" + +echo "Pushing latest commit to origin, with tags" +git push origin master +git push origin master --tags + +echo +echo "Creating local copy of SVN repo ..." +svn co $SVNURL $SVNPATH + +echo "Exporting the HEAD of master from git to the trunk of SVN" +git checkout-index -a -f --prefix=$SVNPATH/trunk/ + +echo "Ignoring github specific files and deployment script" +svn propset svn:ignore "deploy.sh +deploy-common.sh +readme.sh +README.md +.git +.gitattributes +.gitignore +assets" "$SVNPATH/trunk/" + +echo "Changing directory to SVN and committing to trunk" +cd $SVNPATH/trunk/ +# Add all new files that are not set to be ignored +svn status | grep -v "^.[ \t]*\..*" | grep "^?" | awk '{print $2}' | xargs svn add +svn commit --username=$SVNUSER -m "$COMMITMSG" + +echo "Creating new SVN tag & committing it" +cd $SVNPATH +svn copy trunk/ tags/$NEWVERSION1/ +cd $SVNPATH/tags/$NEWVERSION1 +svn commit --username=$SVNUSER -m "Tagging version $NEWVERSION1" + +echo "Removing temporary directory $SVNPATH" +rm -fr $SVNPATH/ + +echo "*** FIN ***" diff --git a/readme.sh b/readme.sh new file mode 100644 index 0000000..35d7216 --- /dev/null +++ b/readme.sh @@ -0,0 +1,96 @@ +#!/bin/bash + + + +# Variables List +TITLE=$(head -n1 readme.txt) +LICENSE=$(cat readme.txt | grep "License URI:" | awk -F// '{ print $2 }' | cat readme.txt | grep "License URI:" | cut -d: -f2,3) +#echo $TITLE $LICENSE + +# Remove Previous Files +if [ -e /tmp/file ] || [ -e /tmp/file1 ] || [ -e /tmp/file2 ] +then + rm /tmp/file* &> /dev/null +fi + + + + +# Add Images +curl -I $1/assets/banner-772x250.png 2> /dev/null | grep '200 OK' &> /dev/null +if [ $? -eq 0 ] +then + echo "![alt text]($1/assets/banner-772x250.png)" &> /tmp/file + echo >> /tmp/file +fi +curl -I $1/assets/banner-772x250.jpg 2> /dev/null | grep '200 OK' &> /dev/null +if [ $? -eq 0 ] +then + echo "![alt text]($1/assets/banner-772x250.jpg)" &> /tmp/file + echo >> /tmp/file +fi +curl -I $1/assets/banner-772x250.jpeg 2> /dev/null | grep '200 OK' &> /dev/null +if [ $? -eq 0 ] +then + echo "![alt text]($1/assets/banner-772x250.jpeg)" &> /tmp/file + echo >> /tmp/file +fi + +# Add Title & Contribute To Temp File +head -n1 readme.txt >> /tmp/file +echo -n Contributors: >> /tmp/file + +# Find No Of Contributors & Send Them To Temp File +for i in $(cat readme.txt | grep ^Contributor | cut -d: -f2 | tr ',' ' ') +do + echo -n " [$i] (http://profiles.wordpress.org/$i)," | tr '\n' ' ' +done >> /tmp/file +echo >> /tmp/file + +# Find License Details +echo $LICENSE | grep 3.0 +if [ $? -eq 0 ] +then + LICENSE="[GPL v3 or later] (http://www.gnu.org/licenses/gpl-3.0.html)" + #echo $LICENSE +else + LICENSE="[GPL v2 or later] ($LICENSE)" + #echo $LICENSE +fi + +# Send License Details To Temp File +echo "License: $LICENSE" >> /tmp/file + + +# Send All The Line Except The Lines All Ready Present in Temp File +cat readme.txt | grep -v "$TITLE" | grep -v Contributors | grep -v License >> /tmp/file + + +# Delete Unwanted Stuff +sed '/^Tags:/,/^Stable tag:/d' /tmp/file &>/tmp/file1 +sed '/^== Upgrade/,/$/d' /tmp/file1 &> /tmp/file2 + +# Add New Line (Needed To Proper Solutions) +#sed -i '/Donate/ i\License: [GPLv2 or later] (http://www.gnu.org/licenses/gpl-2.0.html)' /tmp/file2 + +# Add New Lines For Line Breaks In Github +sed 's/Contributors/\'$'\n&/g' /tmp/file2 &> /tmp/file1 +sed 's/License/\'$'\n&/g' /tmp/file1 &> /tmp/file2 +sed 's/Donate/\'$'\n&/g' /tmp/file2 &> /tmp/file1 + + + +# Replace === to # +sed 's/===/#/g' /tmp/file1 &> /tmp/file2 + +# REplace == to ## +sed 's/==/##/g' /tmp/file2 &> /tmp/file1 + +# Replave = to #### From Description To The End Of File +sed '/Description/,$s/=/####/g' /tmp/file1 &> /tmp/file2 + +# Make Text Bold +sed 's/[Cc]ontributors:/* **Contributors:**/' /tmp/file2 &> /tmp/file1 +sed 's/[Dd]onate [Ll]ink:/* **Donate Link:**/' /tmp/file1 &> /tmp/file2 +sed 's/[Ll]icense:/* **License:**/' /tmp/file2 &> README.md + diff --git a/readme.txt b/readme.txt index 326d161..eda6413 100644 --- a/readme.txt +++ b/readme.txt @@ -1,5 +1,5 @@ -=== Plugin Name === -Contributors: marsjaninzmarsa +=== Query Filter === +Contributors: marsjaninzmarsa, mainpagepl Tags: advanced, query, WP Query, filter, search, widget, custom post type, Taxonomy, meta, custom field Requires at least: 3.0.0 Tested up to: 4.3