-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdeploy.sh
48 lines (37 loc) · 1.28 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
#!/usr/bin/env bash
# Get the plugin slug from this git repository.
PLUGIN_SLUG="${PWD##*/}"
# Get the current release version
TAG=$(sed -e "s/refs\/tags\///g" <<< $GITHUB_REF)
VERSION="${TAG#v}"
# Get the SVN data from wp.org in a folder named `svn`
SVN_URL="https://plugins.svn.wordpress.org/${PLUGIN_SLUG}/"
SVN_DIR="$HOME/svn-${PLUGIN_SLUG}"
svn checkout --depth immediates "$SVN_URL" "$SVN_DIR"
# Switch to SVN directory
cd "$SVN_DIR"
svn update --set-depth infinity trunk
svn update --set-depth infinity tags/$VERSION
# Copy files from release to `svn/trunk`
rsync -rcm --exclude-from="$GITHUB_WORKSPACE/.distignore" "$GITHUB_WORKSPACE/" trunk/ --delete --delete-excluded
# Detect and schedule additions and deletions in SVN
svn status | grep '^[!?]' | while IFS= read -r line; do
status="${line:0:1}"
file="${line:8}"
if [ "$status" = "!" ]; then
svn delete "$file"
elif [ "$status" = "?" ]; then
svn add "$file"
fi
done
# Prepare the files for commit in SVN
svn add --force trunk
# Create the version tag in svn
svn cp "trunk" "tags/$VERSION"
# Prepare the tag for commit
svn add --force tags
# Commit files to wordpress.org.
svn ci --message "Release $TAG" \
--username $SVN_USERNAME \
--password $SVN_PASSWORD \
--non-interactive