-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdeploy.sh
94 lines (72 loc) · 2.64 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/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/wp-menu-cart/"
SVN_DIR="$HOME/svn-wp"
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
#### REPEAT FOR woocommerce-menu-bar-cart ####
# Overwrite plugin name
sed -i -e "s/=== WP Menu Cart ===/=== Menu Cart for WooCommerce ===/g" "$GITHUB_WORKSPACE/readme.txt"
sed -i -e "s/Plugin Name: WP Menu Cart/Plugin Name: Menu Cart for WooCommerce/g" "$GITHUB_WORKSPACE/wp-menu-cart.php"
# Get the SVN data from wp.org in a folder named `svn`
SVN_URL="https://plugins.svn.wordpress.org/woocommerce-menu-bar-cart/"
SVN_DIR="$HOME/svn-wc"
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