Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
The WordPress SEO Release script
#!/bin/sh
# License: GPL v3
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# THE GITHUB ACCESS TOKEN, GENERATE ONE AT: https://github.com/settings/applications (Personal access tokens)
GITHUB_ACCESS_TOKEN="GITHUB_ACCESS_TOKEN"
# ASK INFO
echo "-------------------------------------------"
echo " WORDPRESS SEO RELEASER "
echo "-------------------------------------------"
read -p "VERSION: " VERSION
echo "-------------------------------------------"
read -p "PRESS [ENTER] TO RELEASE WORPDPRESS SEO VERSION "${VERSION}
# VARS - THESE SHOULD BE CHANGED!
ROOT_PATH="/Users/barrykooij/Documents/plugins/wordpress-seo/"
PRODUCT_NAME="wordpress-seo"
PRODUCT_NAME_GIT=${PRODUCT_NAME}"-git"
PRODUCT_NAME_SVN=${PRODUCT_NAME}"-svn"
SVN_REPO="http://plugins.svn.wordpress.org/wordpress-seo/"
GIT_REPO="git@github.com:Yoast/wordpress-seo.git"
# CHECKOUT SVN DIR IF NOT EXISTS
if [[ ! -d $PRODUCT_NAME_SVN ]];
then
echo "No SVN directory found, will do a checkout"
svn checkout $SVN_REPO $PRODUCT_NAME_SVN
fi
# DELETE OLD GIT DIR
rm -Rf $ROOT_PATH$PRODUCT_NAME_GIT
# CLONE GIT DIR
echo "Cloning GIT repo"
git clone $GIT_REPO $PRODUCT_NAME_GIT
# MOVE INTO GIT DIR
cd $ROOT_PATH$PRODUCT_NAME_GIT
# INIT&UPDATE&PULL SUBMODULE(S)
echo "Do the submodule dance"
git submodule init
git submodule update
git submodule foreach git checkout master && git pull
# REMOVE UNWANTED FILES & FOLDERS
echo "Removing unwanted files"
rm -Rf .git
rm -Rf tests
rm -f .gitattributes
rm -f .gitignore
rm -f .gitmodules
rm -f .travis.yml
rm -f Gruntfile.js
rm -f package.json
rm -f .jscrsrc
rm -f .jshintrc
rm -f composer.json
rm -f phpunit.xml
rm -Rf admin/license-manager/.git
# MOVE INTO SVN DIR
cd $ROOT_PATH$PRODUCT_NAME_SVN
# UPDATE SVN
echo "Updating SVN"
svn update
# DELETE TRUNK
echo "Replacing trunk"
rm -Rf trunk/
# COPY GIT DIR TO TRUNK
cp -R $ROOT_PATH$PRODUCT_NAME_GIT trunk/
# DO THE ADD ALL NOT KNOWN FILES UNIX COMMAND
svn add --force * --auto-props --parents --depth infinity -q
# DO THE REMOVE ALL DELETED FILES UNIX COMMAND
svn rm $( svn status | sed -e '/^!/!d' -e 's/^!//' )
# COPY TRUNK TO TAGS/$VERSION
svn copy trunk tags/${VERSION}
# DO A SVN STATUS
svn status
# REMOVE THE GIT DIR
echo "Removing GIT dir"
rm -Rf $ROOT_PATH$PRODUCT_NAME_GIT
# CREATE THE GITHUB RELEASE
echo "Creating GITHUB release"
API_JSON=$(printf '{"tag_name": "%s","target_commitish": "master","name": "%s","body": "Release of version %s","draft": false,"prerelease": false}' $VERSION $VERSION $VERSION)
curl --data "$API_JSON" https://api.github.com/repos/Yoast/${PRODUCT_NAME}/releases?access_token=${GITHUB_ACCESS_TOKEN}
# DONE, BYE
echo "WORDPRESS SEO RELEASER DONE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment