Skip to content

Instantly share code, notes, and snippets.

@igmoweb
Forked from uglyrobot/package-plugin
Last active August 29, 2015 14:25
Show Gist options
  • Save igmoweb/9815ef7a612ea653dbfb to your computer and use it in GitHub Desktop.
Save igmoweb/9815ef7a612ea653dbfb to your computer and use it in GitHub Desktop.
#!/bin/bash
BROWSER_PATH='open /Applications/Google\ Chrome.app'
if [[ $# -eq 0 ]] ; then
echo "Please enter a version number:"
read VERSION
else
VERSION=$1
fi
if [[ -z "$VERSION" ]] ; then
echo "Sorry, I need a version number!"
exit 1
fi
#check that the plugin/theme version number matches what you provided. Note if multiple root php files have a "Version" header
# line it will only grab the first it finds. Also if a theme and you have a php file in root with "Version" could cause mismatch.
HEADERVERSION=`grep -m 1 --include={*.php,style.css} "^Version" * | awk -F' ' '{print $2}' | sed 's/[[:space:]]//g'`
if [ "$VERSION" != "$HEADERVERSION" ]; then echo "Version doesn't match the plugin/theme header. Exiting...."; exit 2; fi
PROJECTID=`grep -m 1 --include={*.php,style.css} "^WDP ID\:" * | awk -F' ' '{print $3}' | sed 's/[[:space:]]//g'`
#get the changelog message
echo "Enter your multiline changelog then ctrl-d on a new line when done:"
MSG=$(cat)
if [[ -z "$MSG" ]] ; then
echo "Sorry, I need a changelog for this release!"
exit 3
fi
#get plugin slug/name from current directory
NAME=${PWD##*/}
git tag -a $VERSION -m "$MSG"
git push origin $VERSION
git-archive-all --force-submodules --prefix $NAME/ ~/Desktop/$NAME-$VERSION.zip
echo "Tagged in bitbucket and Packaged as $NAME-$VERSION.zip on your desktop."
eval "$BROWSER_PATH 'https://premium.wpmudev.org/wp-admin/edit.php?post_type=project&page=projects-manage&manage_files='$PROJECTID"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment