forked from crosspeaksoftware/woo-address-book
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease.sh
executable file
·61 lines (44 loc) · 1.93 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
#!/bin/bash
set -e
# Wordpress.org username
wordpressuser="hallme"
# Wordpress.org plugin slug
package="woo-address-book"
version=$1
if [[ ! $version ]]; then
echo "Needs a version number as argument"
exit 1
fi
echo "Releasing version ${version}"
echo "Setting version number in readme.txt and php files"
perl -pi -e "s/Stable tag: .*/Stable tag: ${version}/g" readme.txt
perl -pi -e "s/Version: .*/Version: ${version}/g" woocommerce-address-book.php
perl -pi -e "s/\@version .*/\@version ${version}/g" includes/class-wc-address-book.php
perl -pi -e "s/this->version = '.*';/this->version = '${version}';/g" includes/class-wc-address-book.php
if ([[ $(git status | grep readme.txt) ]] || [[ $(git status | grep woocommerce-address-book.php) ]]); then
echo "Committing changes"
git add readme.txt
git add woocommerce-address-book.php
git add includes/class-wc-address-book.php
git commit -m"Update readme with new stable tag $version"
fi
echo "Tagging locally"
git tag $version
echo "Pushing tag to git"
git push --tags origin main
echo "Checking out current version on Wordpress SVN"
svn co https://plugins.svn.wordpress.org/${package}/trunk /tmp/release-${package}
./makedist.sh
echo "Copying in updated files"
rsync -rv --delete --exclude ".svn" dist/. /tmp/release-${package}/.
cd /tmp/release-${package}/
# Add and delete new/old files.
svn status | grep "^!" | awk '{print $2"@"}' | tr \\n \\0 | xargs -0 svn delete || true
svn status | grep "^?" | awk '{print $2"@"}' | tr \\n \\0 | xargs -0 svn add || true
echo "Commiting version ${version} to Wordpress SVN"
svn commit --username ${wordpressuser} -m"Releasing version ${version}" /tmp/release-${package}
echo "Creating version ${version} SVN tag"
svn copy --username ${wordpressuser} https://plugins.svn.wordpress.org/${package}/trunk https://plugins.svn.wordpress.org/${package}/tags/${version} -m"Creating new ${version} tag"
echo "Cleaning up"
rm -rf /tmp/release-${package}
echo "Done"