Skip to content

Commit 2eba9d6

Browse files
authored
Merge pull request #5 from razorpay/release_script
Added release shell script
2 parents 268d051 + 4e8e794 commit 2eba9d6

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed

release.sh

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#! /bin/bash
2+
set -euo pipefail
3+
#
4+
# Source: https://gist.github.com/philbuchanan/8188898
5+
# License: GNU GPL 2.1
6+
# Script to deploy from Github to WordPress.org Plugin Repository
7+
# A modification of Dean Clatworthy's deploy script as found here: https://github.com/deanc/wordpress-plugin-git-svn
8+
# The difference is that this script lives in the plugin's git repo & doesn't require an existing SVN repo.
9+
# Slightly adapted
10+
11+
SVNUSER=razorpay
12+
PLUGINSLUG='razorpay-payment-button-for-siteorigin'
13+
14+
# main config
15+
CURRENTDIR="$(pwd)/"
16+
17+
# git config
18+
GITPATH="$CURRENTDIR" # this file should be in the base of your git repository
19+
20+
# svn config
21+
SVNPATH="/tmp/$PLUGINSLUG" # path to a temp SVN repo. No trailing slash required and don't add trunk.
22+
# Remote SVN repo on wordpress.org, with no trailing slash
23+
SVNURL="https://plugins.svn.wordpress.org/$PLUGINSLUG"
24+
25+
# Let's begin...
26+
echo ".........................................."
27+
echo
28+
echo "Preparing to deploy wordpress plugin"
29+
echo
30+
echo ".........................................."
31+
echo
32+
33+
# Check version in readme.txt
34+
RELEASE_VERSION=$(grep "^Stable tag" "$GITPATH/readme.txt" | awk -F' ' '{print $3}')
35+
COMMITMSG="Update: $RELEASE_VERSION"
36+
37+
echo "Tagging new version in git"
38+
git tag -a "v$RELEASE_VERSION" -m "$COMMITMSG"
39+
40+
echo "Pushing latest commit to origin, with tags"
41+
git push origin master
42+
git push origin master --tags
43+
44+
echo "Creating local copy of SVN repo ..."
45+
svn co $SVNURL $SVNPATH
46+
47+
echo "Exporting the HEAD of master from git to the trunk of SVN"
48+
git checkout-index -a -f --prefix=$SVNPATH/trunk/
49+
50+
echo "Ignoring github specific & deployment script"
51+
svn propset svn:ignore "release.sh
52+
.git
53+
.gitignore" "$SVNPATH/trunk/"
54+
55+
# TODO: move assets to git repo
56+
# echo "Moving assets-wp-repo"
57+
# mkdir $SVNPATH/assets/
58+
# mv $SVNPATH/trunk/assets-wp-repo/* $SVNPATH/assets/
59+
# svn add $SVNPATH/assets/
60+
# svn delete $SVNPATH/trunk/assets-wp-repo
61+
62+
echo "Changing directory to SVN"
63+
cd "$SVNPATH/trunk/"
64+
# Add all new files that are not set to be ignored
65+
svn status | grep -v "^.[ \t]*\..*" | grep "^?" | awk '{print $2}' | xargs svn add || true
66+
echo "committing to trunk"
67+
svn commit --username="$SVNUSER" -m "$COMMITMSG"
68+
69+
# echo "Updating WP plugin repo assets & committing"
70+
# cd $SVNPATH/assets/
71+
# svn commit --username=$SVNUSER -m "Updating wp-repo-assets"
72+
73+
echo "Creating new SVN tag & committing it"
74+
cd "$SVNPATH"
75+
svn copy trunk/ "tags/$RELEASE_VERSION"
76+
cd "$SVNPATH/tags/$RELEASE_VERSION"
77+
svn commit --username="$SVNUSER" -m "Tagging version $RELEASE_VERSION"
78+
79+
echo "*** FIN ***"

0 commit comments

Comments
 (0)