-
Notifications
You must be signed in to change notification settings - Fork 1
/
bprelease.sh
executable file
·224 lines (190 loc) · 6.29 KB
/
bprelease.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
#!/bin/bash
dryrun=0
use_existing_checkouts=0
while getopts "v:db:e" opt; do
case $opt in
v)
ver=$OPTARG
;;
d)
dryrun=1
;;
b)
branch=$OPTARG
;;
e)
use_existing_checkouts=1
;;
\?)
echo 'No'
;;
esac
done
# Check that there is a version provided
if [ "$ver" == '' ]; then
echo "No version provided. Please provide a value for -v."
exit
fi
# Check that there is a branch provided
if [ "$branch" == '' ]; then
echo "No branch provided. Please provide a value for -b."
exit
fi
if [ $dryrun -eq 0 ]; then
read -n 1 -p "I understand that this is NOT a dry run (y/n)? " answer
echo ""
if [ "$answer" != 'y' ]; then
echo "Get outta here then"
exit 1
fi
fi
echo "Preparing BuddyPress $ver from source branch $branch."
if [ $dryrun -eq 0 ]; then
echo "*** This is NOT a dry run ***"
else
echo "*** This is a dry run ***"
fi
# Set up the buddypress.svn checkout.
if [ $use_existing_checkouts -eq 0 ]; then
echo "Getting a checkout of the $branch branch."
# Remove existing bp working directory.
if [ -d "bp" ]; then
rm -rf ./bp
fi
# Get a checkout of the branch.
svn co --ignore-externals http://buddypress.svn.wordpress.org/branches/$branch bp
else
if [[ ! -d 'bp' ]] || [[ ! -f 'bp/Gruntfile.js' ]]; then
echo "No checkout found. Please try again without the -e flag."
exit 1
else
echo "Using your existing $branch checkout."
fi
fi
cd bp
# Version number replacements.
# Version: x.y.z in bp-loader.php
ver_regex='s/\(^ \* Version\:\s\+\)\([0-9\.]\+\)/\1'"$ver"/
sed -i "{$ver_regex}" bp-loader.php
sed -i "{$ver_regex}" src/bp-loader.php
# $this->version in bp-loader.php
inline_ver_regex="s/\(\$this\->version\s\+= '\)[0-9\.]\+/\1""$ver"/
sed -i "{$inline_ver_regex}" src/bp-loader.php
# Stable tag in readme.txt
stable_regex='s/\(^Stable tag\:\s\+\)\([0-9\.]\+\)/\1'"$ver"/
sed -i "{$stable_regex}" src/readme.txt
# Stable tag in package.json
package_regex='s/\(\"version\"\: \?\)\"[0-9\.]\+\"/\1"'"$ver"\"/
sed -i "{$package_regex}" package.json
# Upgrade Notice and Changelog
# Only add it if it hasn't already been added.
already=$( grep -c "= $ver =" src/readme.txt )
if [ $already -eq 0 ]; then
ver_hyphens="$(sed -e "s/\./-/g" <<< "$ver")"
see="\n\n= $ver =\nSee: https:\/\/codex.buddypress.org\/releases\/version-$ver_hyphens\/"
upgrade_regex='s/\(\(Upgrade Notice\|Changelog\).*\)/\1'"$see"/g
sed -i "{$upgrade_regex}" src/readme.txt
# $this->db_version in bp-loader.php should also only be updated when necessary.
#lastrev="$(svn log -l 1 http://buddypress.svn.wordpress.org | grep -oP "^r([0-9]+) \| ")"
#lastrev="$(sed -e "s/[^0-9]//g" <<< "$lastrev")"
#db_ver_regex="s/\(\$this\->db_version\s\+= \)[0-9\.]\+/\1""$lastrev"/
sed -i "{$db_ver_regex}" src/bp-loader.php
fi
echo "Version numbers bumped to $ver."
# TEMP: Don't run jsvalidate
#sed -i "s/'jsvalidate\:src',//" Gruntfile.js
#sed -i "s/'jsvalidate\:build',//" Gruntfile.js
# Commit version bumps.
commit_message_bump="Bumping version numbers to $ver."
if [ $dryrun -eq 0 ]; then
read -n 1 -p "Ready to commit and tag in buddypress.svn.wordpress.org? (y/n)? " answer
echo ""
if [ "$answer" != 'y' ]; then
echo "Are you yaller?"
exit 1
fi
svn ci -m "$commit_message_bump"
else
echo "DRY RUN: svn ci -m \"$commit_message_bump\""
fi
# Create buddypress.svn.wordpress.org tag.
commit_message_tag="Create tag $ver."
echo "Creating tag."
if [ $dryrun -eq 0 ]; then
svn cp http://buddypress.svn.wordpress.org/branches/$branch http://buddypress.svn.wordpress.org/tags/$ver -m "$commit_message_tag"
else
echo "DRY RUN: svn cp http://buddypress.svn.wordpress.org/branches/$branch http://buddypress.svn.wordpress.org/tags/$ver -m \"$commit_message_tag\""
fi
# Build the release.
npm install
grunt build # Not 'release', because we don't want bbPress.
# Get a checkout of plugins.svn branch.
cd ..
if [ $use_existing_checkouts -eq 0 ]; then
# Remove existing wporg working directory.
if [ -d "wporg" ]; then
rm -rf ./wporg
fi
remote_branches=$(svn ls http://plugins.svn.wordpress.org/buddypress/branches)
if grep -q $branch <<< "$remote_branches"; then
echo "Remote branch $branch exists"
else
echo "Remote branch $branch does not exist. Creating from trunk..."
svn cp http://plugins.svn.wordpress.org/buddypress/trunk http://plugins.svn.wordpress.org/buddypress/branches/$branch -m "Creating $branch branch from trunk."
fi
svn co --ignore-externals http://plugins.svn.wordpress.org/buddypress/branches/$branch wporg
fi
# Sync the changes from the bporg checkout to the wporg checkout.
mv wporg/.svn ./svn-files
rm -rf wporg/*
cp -R bp/build/* wporg/
mv ./svn-files wporg/.svn
#rsync -r --exclude='.svn' bp/src/ wporg/
# Remove bbPress from the checkout and set the external (should already be done, but just in case).
cd wporg
rm -rf bp-forums/bbpress
svn propset svn:externals 'bbpress https://bbpress.svn.wordpress.org/tags/1.2/' bp-forums
# Before committing, roll back the readme, so that the stable tag is not changed.
svn diff readme.txt > ../readme.diff
svn revert readme.txt
# Clean up the index.
svn add --force .
svn rm $( svn status | sed -e '/^!/!d' -e 's/^!//' )
svn status
# Commit to branch.
echo ''
echo "Committing to plugins.svn.wordpress.org $branch branch."
if [ $dryrun -eq 0 ]; then
read -n 1 -p "Ready to commit and tag? (y/n)? " answer
echo ""
if [ "$answer" != 'y' ]; then
echo "Boo hoo"
exit 1
fi
svn ci -m "Sync to plugins.svn.wordpress.org for $ver release."
else
echo "DRY RUN: svn ci -m \"Sync to plugins.svn.wordpress.org for $ver release.\""
fi
# svn cp to the new tag
# Create buddypress.svn.wordpress.org tag.
commit_message_tag="Create tag $ver."
echo "Creating tag."
if [ $dryrun -eq 0 ]; then
svn cp http://plugins.svn.wordpress.org/buddypress/branches/$branch http://plugins.svn.wordpress.org/buddypress/tags/$ver -m "$commit_message_tag"
else
echo "DRY RUN: svn cp http://plugins.svn.wordpress.org/buddypres/branches/$branch http://plugins.svn.wordpress.org/tags/$ver -m \"$commit_message_tag\""
fi
# Then bump stable tag in trunk
echo "One more step: Bump the stable tag in readme.txt."
patch -p0 < ../readme.diff
if [ $dryrun -eq 0 ]; then
read -n 1 -p "Shall I do the honors? (y/n)? " answer
echo ""
if [ "$answer" != 'y' ]; then
echo "Don't forget to do it yourself"
exit 1
fi
svn ci -m "Bump stable tag to $ver."
else
echo "DRY RUN: svn ci -m \"Bump stable tag to $ver.\""
fi