forked from CodeAtCode/freemius-suite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease.sh
executable file
·68 lines (55 loc) · 1.81 KB
/
release.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
#!/bin/bash
# Slack bash script https://gist.github.com/andkirby/67a774513215d7ba06384186dd441d9e
file=$(readlink -f "$1")
if [[ ${file: -4} != ".zip" ]]; then
echo "The file $file is not a zip."
exit 1
fi
folder=$(basename "$1")
r=$(( RANDOM % 10 ));
wd="$folder-$r"
echo "- Extracting free version $file"
cd "/tmp/" || exit
mkdir "$wd"
extract="/tmp/$wd/upload"
if [ ! -f "$file" ]; then
echo "$file doesn't exists"
exit
fi
unzip "$file" -d "$extract" > /dev/null
cd "$wd" || exit
# Get the plugin root file
rootfile=$(grep -R "WordPress-Plugin-Boilerplate-Powered" . | awk -F: '{print $1}')
# Get plugin version
version=$(grep " * Version:" "$rootfile" | awk -F' ' '{print $NF}')
# slack-message "Deploy on WordPress SVN of $version started!"
# Get the domain for WP SVN
wpdomain=$(grep " * Text Domain:" "$rootfile" | awk -F' ' '{print $NF}')
if [ -z "$wpdomain" ]; then
exit 1
fi
echo "- Deploy on SVN started!"
echo "- Wait few minutes for the procedure!"
echo "- Cloning SVN locally"
svn co "https://plugins.svn.wordpress.org/$wpdomain" > /dev/null
echo "- Copying new plugin version on SVN locally"
cp -r "$extract/$wpdomain/." ./"$wpdomain"/trunk
cp -r "./$wpdomain"/trunk/. "$wpdomain"/tags/"$version"
echo "- Deploying new plugin version on SVN remote"
cd "$wpdomain" || exit
# This command force to add all the files, also if they are new
svn add --force * --auto-props --parents --depth infinity -q > /dev/null
svn ci -m "tagging version $version" 2>&1 | grep 'Error running context'
if [[ $? -eq 0 ]]
then
slack-message "Error on deploy on WordPress SVN of $version!"
echo "- Deploy of the new free version failed!"
exit 0
else
slack-message "Deploy on WordPress SVN of $version done!"
echo "- Deploy of the new free version done!"
exit 1
fi
cd /tmp/ || exit
rm -fr "./$wd"
echo " "