-
-
Save uglyrobot/e872d1a9efc122b6bae2 to your computer and use it in GitHub Desktop.
#!/bin/bash | |
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" * | sed -e 's/^[ \t]*//' | 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 | |
#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." |
Also this is specific to Mac OSX. You'll have to rewrite some paths for other OSes.
Thanks!
Should work fine on most Linux distributions also.
Great script Aaron, thanks
Works sweet!
Also to add, if you've got your repos on different volumes, you can run git-archive-all via python without building it, put the python script on the same volume as your repos. Thanks to SH for suggesting this.
Hey hey.
If anyone is interested, I forked this Gist in: https://gist.github.com/igmoweb/9815ef7a612ea653dbfb
The difference is that as soon as the new tag is generated, Google Chrome is opened in the project page (so you won't need to copy the WPMU ID number and paste it in the URL or go to projects in wpmu.org, etc. ), it just saves some time and avoid mistakes.
You only need to change the BROWSER_PATH variable (it's actually a command that opens the Browser)
Cheers.
Simply call this script (put it in your /usr/local/bin & make executable or alias) while inside your plugin directory. Example if I'm in "wp-content/plugins/pro-sites/" I call "package-plugin", then get prompted for a version number and changelog.
Note that this requires this to be installed: https://github.com/Kentzo/git-archive-all for generating clean zip files with submodules.