Skip to content

Commit

Permalink
Introduce a WordPress.org deployment script.
Browse files Browse the repository at this point in the history
  • Loading branch information
bradyvercher committed Sep 7, 2016
1 parent a65e01b commit 79eb7b0
Showing 1 changed file with 73 additions and 0 deletions.
73 changes: 73 additions & 0 deletions bin/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/bin/bash

# Based on the GitHub to WordPress.org Deploy Script by Mike Jolley.
# https://github.com/mikejolley/github-to-wordpress-deploy-script

SLUG="simple-image-widget"
VERSION=$1

if [[ "" = "$VERSION" ]]; then
read -p "Enter the version: " VERSION
fi

ARCHIVE="dist/$SLUG-$VERSION.zip"

# Make sure the package archive exists.
if [[ ! -f $ARCHIVE ]]; then
echo "Package archive doesn't exist at $ARCHIVE."
exit
fi

# Check out the SVN repository.
if [[ ! -d svn ]]; then
svn checkout "https://plugins.svn.wordpress.org/$SLUG" svn
fi

# Update SVN.
svn update svn || { echo "Unable to update SVN."; exit 1; }

# Delete trunk.
rm -rf svn/trunk

# Unzip the distribution package.
unzip -q "dist/$SLUG-$VERSION.zip" -d svn

cd svn

# Move unzipped directory to trunk.
mv ${SLUG} trunk

# Add all unknown files to SVN.
svn add --force * --auto-props --parents --depth infinity -q

# Remove all deleted files from SVN.
MISSING_PATHS=$( svn status | sed -e '/^!/!d' -e 's/^!//' )

# Iterate over file paths.
for MISSING_PATH in $MISSING_PATHS; do
svn rm --force "$MISSING_PATH"
done

# Tag trunk.
echo "Copying trunk to new tag."
svn copy trunk tags/${VERSION} || { echo "Unable to create tag."; exit 1; }

# Show status.
echo
echo "Showing SVN status."
svn status

# Confirm deploy.
read -p "Are you sure you want to release version $VERSION? " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 1
fi

# Deploy to WordPress.org.
echo
echo "Committing to WordPress.org. This may take a while..."
svn commit -m "Release $VERSION." || { echo "Unable to commit."; exit 1; }

cd ..
rm -rf svn

0 comments on commit 79eb7b0

Please sign in to comment.