-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 56e5f9d
Showing
5 changed files
with
215 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## 0.5 | ||
* Release date: January 7, 2016 | ||
* Initial release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# GIT to WordPress Plugin Directory Release Script | ||
|
||
WordPress plugins are often hosted on GitHub or other GIT repositories for development purposes but then pushed to the WordPress Plugin SVN infrastruture for release in the Plugin Directory. | ||
|
||
This script automates the process with a simple bash shell script. | ||
|
||
This script was originally based on [code](https://github.com/WP-API/WP-API/blob/develop/bin/release.sh) from the [WP-API](https://github.com/WP-API/WP-API) project. | ||
|
||
## Installation | ||
|
||
The basic script should work for simple plugins without alteration, follow these instructions to install it in your GIT repo for use in the release process: | ||
|
||
1. Create a new directory named "bin" in the root of your GIT repo and copy "release.sh" to it. | ||
2. If you already have a readme.txt file, copy it to the same "bin" directory and rename it to "readme.template", otherwise grab the sample template file from "Sample Templates" directory and edit it as required. | ||
3. Edit your new readme.template file and the hard coded tag name in the "Stable Tag:" line with "{{TAG}}". You can use this tag in multiple places in the file if you choose to. | ||
4. Still in your readme.template file, make sure the changelog is the last section of your file and has 1 blank line after it. | ||
5. If you have a CHANGES.md file, make sure it is in the same format as the sample in the "Sample Templates" directory and is in the root of your GIT repo, if you don't create one. | ||
6. Double check to make sure your execute bit is set on the release.sh file. | ||
7. Commit your changes to your GIT repo. | ||
|
||
## Usage | ||
|
||
You can run the script from either the GIT repo's root directory or from within the "bin" directory. | ||
|
||
The script has two parameters: | ||
|
||
1. Tag to release. | ||
2. SVN user name to use. | ||
|
||
To do a release, do the following: | ||
|
||
1. Tag a release in your GIT repo. | ||
2. Change in to the "bin" directory of the repo. | ||
3. Run "./release.sh TAG UserName" | ||
|
||
The script will do several things and then ask for confirmation to commit the changes to the SVN tree. | ||
|
||
At this time you have the opportunity to verify what will be commit, the working copy will be in your system's temporary directory. | ||
|
||
If everything is ok, you MUST type in "YES", all in capitals and then hit enter. | ||
|
||
The script will then commit the changes to the SVN tree and you may be prompted for your SVN password (if you are it will happen twice, once for the commit and once for the tag). | ||
|
||
## Advanced Items | ||
|
||
The basic script assumes several things which may not be true for your install, things you should check for are: | ||
|
||
- The script assumes your GIT check directory is the slug of your WordPress plugin. You can override this by editing the script and changing the "PLUGIN=" line to the correct slug. | ||
- The system command "mktemp" is used to store the temporary working copy of the plugin, you may want to change this if you have a busy system and don't want to look through a pile of temp directories to find the one you are looking for. | ||
- By default the following files are not commited to the SVN repo: README.md, CHANGES.md and the "bin" directory. If you have other files you wish to exclude, edit the script and go down to the "# Remove special files" section and add them to the list of files to remove. | ||
- The commit messages are very basic, if you want to have something more meaningful to your project, edit the script at the "# Commit the changes" line and "# tag_ur_it" line. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
## X.Y | ||
* The only lines that are important here are the "## X.Y" version lines. | ||
* All other text is simply appended on to the readme.txt file when it is generated. | ||
* X.Y can be any format and the ## will be converted to == for the readme.txt file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
=== Sample Plugin === | ||
Contributors: gregross | ||
Donate link: http://toolstack.com/donate | ||
Plugin URI: http://toolstack.com/gtwdrs | ||
Author URI: http://toolstack.com | ||
Tags: sample | ||
Requires at least: 4.4 | ||
Tested up to: 4.4 | ||
Stable tag: {{TAG}} | ||
License: GPLv2 | ||
License URI: http://www.gnu.org/licenses/gpl-2.0.html | ||
|
||
A sample readme file. | ||
|
||
== Description == | ||
|
||
A sample readme template file for use with the GIT to WordPress Plugin Directory Release Script | ||
|
||
== Installation == | ||
|
||
Sample install steps. | ||
|
||
== Frequently Asked Questions == | ||
|
||
= TBD = | ||
|
||
TBD | ||
|
||
== Changelog == |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
# release.sh | ||
# | ||
# Takes a tag to release, and syncs it to WordPress.org | ||
# | ||
# Notes: | ||
# - You must pass in a valid tag to the script as the first parameter | ||
# - You can pass an SVN user name (case sensitive) as the second parameter of the script if your SVN account is not the same as your current user id. | ||
# - You may be prompted for your SVN password. | ||
# - By default the plugin name used for WordPress.org is the directory name, if this is not the case, change the "PLUGIN=" line below. | ||
# - If the tag already exists in SVN the script will exit. | ||
# - The script will handle both added and deleted files. | ||
|
||
TAG=$1 | ||
INBIN="" | ||
|
||
# Check to see if we're in the bin directory, if so go up one as the script assumes we're in the root of the git repo. | ||
if [ "${PWD##*/}" == "bin" ]; then | ||
cd .. | ||
INBIN="/bin" | ||
fi | ||
|
||
PLUGIN="${PWD##*/}" | ||
TMPDIR=`mktemp -d` | ||
TARFILE=`mktemp` | ||
PLUGINDIR="$PWD" | ||
PLUGINSVN="https://plugins.svn.wordpress.org/$PLUGIN" | ||
|
||
if [ "$2" != "" ]; then | ||
SVN_OPTIONS=" --username $2" | ||
fi | ||
|
||
# Fail on any error | ||
set -e | ||
|
||
# Is the tag valid? | ||
if [ -z "$TAG" ] || ! git rev-parse "$TAG" > /dev/null; then | ||
echo "Invalid tag. Make sure you tag before trying to release." | ||
cd "$PLUGINDIR$INBIN" | ||
exit 1 | ||
fi | ||
|
||
if [[ $VERSION == "v*" ]]; then | ||
# Starts with an extra "v", strip for the version | ||
VERSION=${TAG:1} | ||
else | ||
VERSION="$TAG" | ||
fi | ||
|
||
|
||
# Disable error trapping and then check if it already exist in SVN. | ||
set +e | ||
|
||
svn info "$PLUGINSVN/tags/$VERSION" > /dev/null 2>&1 | ||
if (( $? == 0 )); then | ||
echo "Tag already exists in SVN!" | ||
cd "$PLUGINDIR$INBIN" | ||
exit 1 | ||
fi | ||
|
||
set -e | ||
|
||
if [ -d "$TMPDIR" ]; then | ||
# Wipe it clean | ||
rm -rf "$TMPDIR" | ||
fi | ||
|
||
# Ensure the directory exists first | ||
mkdir "$TMPDIR" | ||
|
||
# Grab an unadulterated copy of SVN | ||
svn co "$PLUGINSVN/trunk" "$TMPDIR" > /dev/null | ||
|
||
# Extract files from the Git tag to there | ||
git archive --format="tar" "$TAG" > "$TARFILE" | ||
tar -C "$TMPDIR" -xf "$TARFILE" | ||
|
||
# Switch to build dir | ||
cd "$TMPDIR" | ||
|
||
# Run build tasks | ||
sed -e "s/{{TAG}}/$VERSION/g" < "$PLUGINDIR/bin/readme.template" > readme.temp | ||
sed -e "s/##\(.*\)/=\1 =/g" < "$PLUGINDIR/CHANGES.md" > changelog.temp | ||
cat readme.temp changelog.temp > readme.txt | ||
rm readme.temp | ||
rm changelog.temp | ||
|
||
# Remove special files | ||
rm README.md | ||
rm CHANGES.md | ||
rm -r "bin" | ||
|
||
# Disable error trapping and then check to see if there are any results, if not, don't run the svn add command as it fails. | ||
set +e | ||
svn status | grep -v "^.[ \t]*\..*" | grep "^?" | ||
if (( $? == 0 )); then | ||
set -e | ||
svn status | grep -v "^.[ \t]*\..*" | grep "^?" | awk '{print $2}' | xargs svn add $SVN_OPTIONS | ||
fi | ||
|
||
# Find any deleted files and run svn delete. | ||
set +e | ||
tar -df "$TARNAME" 2>&1 | grep "Not found in archive" | ||
if (( $? == 0 )); then | ||
set -e | ||
tar -df "$TARNAME" 2>&1 | grep "Not found in archive" | sed -e "s/tar: \(.*\): Warning:.*/\1/g" | xargs svn delete $SVN_OPTIONS | ||
fi | ||
|
||
set -e | ||
|
||
rm "$TARFILE" | ||
|
||
# Pause to allow checking | ||
echo "About to commit $VERSION. Double-check $TMPDIR to make sure everything looks fine." | ||
read -p "Type 'YES' in all capitals and then return to continue." | ||
|
||
if [[ "$REPLY" == "YES" ]]; then | ||
|
||
# Commit the changes | ||
svn commit -m "Updates for $VERSION release." $SVN_OPTIONS | ||
|
||
# tag_ur_it | ||
svn copy "$PLUGINSVN/trunk" "$PLUGINSVN/tags/$VERSION" -m "Tagged v$VERSION." $SVN_OPTIONS | ||
|
||
fi | ||
|
||
# Go back to where we started and clean up the temp directory. | ||
cd "$PLUGINDIR$INBIN" | ||
rm -rf "$TEMPDIR" |