-
Notifications
You must be signed in to change notification settings - Fork 1
/
deploy.sh
executable file
·66 lines (51 loc) · 1.78 KB
/
deploy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env bash
if [[ -z "$TRAVIS" ]]; then
echo "Script is only to be run by Travis CI" 1>&2
exit 1
fi
if [[ -z "$WP_ORG_USERNAME" ]]; then
echo "WordPress.org username not set" 1>&2
exit 1
fi
if [[ -z "$WP_ORG_PASSWORD" ]]; then
echo "WordPress.org password not set" 1>&2
exit 1
fi
if [[ -z "$TRAVIS_TAG" ]]; then
echo "Build must be tag" 1>&2
exit 0
fi
SLUG="ebanx-local-payment-gateway-for-woocommerce"
SVN_ROOT_PATH="$TRAVIS_BUILD_DIR/build/svn"
# Clean up any previous svn dir
rm -fR $SVN_ROOT_PATH
echo "Performing Checkout from http://svn.wp-plugins.org/$SLUG"
# Checkout the SVN repo
svn co -q "http://svn.wp-plugins.org/$SLUG" $SVN_ROOT_PATH
# Erase trunk
rm -fR "$SVN_ROOT_PATH/trunk"
# Create trunk directory
mkdir $SVN_ROOT_PATH/trunk
echo "Synchronizing trunk"
# Copy our new version of the plugin into trunk
rsync -r -p --exclude=build --exclude=tests --exclude=_vendor $TRAVIS_BUILD_DIR/* $SVN_ROOT_PATH/trunk
# Erase possible broken version
rm -fR "$SVN_ROOT_PATH/tags/$TRAVIS_TAG"
# Add new version tag
mkdir $SVN_ROOT_PATH/tags/$TRAVIS_TAG
echo "Synchronizing tag $TRAVIS_TAG"
# Copy our new version of the plugin into tag directory
rsync -r -p --exclude=build --exclude=tests --exclude=_vendor $TRAVIS_BUILD_DIR/* $SVN_ROOT_PATH/tags/$TRAVIS_TAG
echo "Generating diff"
# Add new files to SVN
svn stat $SVN_ROOT_PATH | grep '^?' | awk '{print $2}' | xargs -I x svn add x@
# Remove deleted files from SVN
svn stat $SVN_ROOT_PATH | grep '^!' | awk '{print $2}' | xargs -I x svn rm --force x@
echo "Uploading to SVN"
# Commit to SVN
svn ci --no-auth-cache --username $WP_ORG_USERNAME --password $WP_ORG_PASSWORD $SVN_ROOT_PATH -m "Deploy version $TRAVIS_TAG"
echo "Cleaning temp dirs"
# Remove SVN temp dir
rm -fR $SVN_ROOT_PATH
rm -rf vendor
mv _vendor vendor