|
| 1 | +#!/bin/bash |
| 2 | +dryrun=0 |
| 3 | +use_existing_checkouts=0 |
| 4 | +while getopts "v:db:e" opt; do |
| 5 | + case $opt in |
| 6 | + v) |
| 7 | + ver=$OPTARG |
| 8 | + ;; |
| 9 | + d) |
| 10 | + dryrun=1 |
| 11 | + ;; |
| 12 | + b) |
| 13 | + branch=$OPTARG |
| 14 | + ;; |
| 15 | + e) |
| 16 | + use_existing_checkouts=1 |
| 17 | + ;; |
| 18 | + \?) |
| 19 | + echo 'No' |
| 20 | + ;; |
| 21 | + |
| 22 | + esac |
| 23 | +done |
| 24 | + |
| 25 | +# Check that there is a version provided |
| 26 | +if [ "$ver" == '' ]; then |
| 27 | + echo "No version provided. Please provide a value for -v." |
| 28 | + exit |
| 29 | +fi |
| 30 | + |
| 31 | +# Check that there is a branch provided |
| 32 | +if [ "$branch" == '' ]; then |
| 33 | + echo "No branch provided. Please provide a value for -b." |
| 34 | + exit |
| 35 | +fi |
| 36 | + |
| 37 | +if [ $dryrun -eq 0 ]; then |
| 38 | + read -n 1 -p "I understand that this is NOT a dry run (y/n)? " answer |
| 39 | + echo "" |
| 40 | + if [ "$answer" != 'y' ]; then |
| 41 | + echo "Get outta here then" |
| 42 | + exit 1 |
| 43 | + fi |
| 44 | +fi |
| 45 | + |
| 46 | +echo "Preparing BuddyPress $ver from source branch $branch." |
| 47 | + |
| 48 | +if [ $dryrun -eq 0 ]; then |
| 49 | + echo "*** This is NOT a dry run ***" |
| 50 | +else |
| 51 | + echo "*** This is a dry run ***" |
| 52 | +fi |
| 53 | + |
| 54 | +# Set up the buddypress.svn checkout. |
| 55 | +if [ $use_existing_checkouts -eq 0 ]; then |
| 56 | + echo "Getting a checkout of the $branch branch." |
| 57 | + # Remove existing bp working directory. |
| 58 | + if [ -d "bp" ]; then |
| 59 | + rm -rf ./bp |
| 60 | + fi |
| 61 | + |
| 62 | + # Get a checkout of the branch. |
| 63 | + svn co http://buddypress.svn.wordpress.org/branches/$branch bp |
| 64 | +else |
| 65 | + if [[ ! -d 'bp' ]] || [[ ! -f 'bp/Gruntfile.js' ]]; then |
| 66 | + echo "No checkout found. Please try again without the -e flag." |
| 67 | + exit 1 |
| 68 | + else |
| 69 | + echo "Using your existing $branch checkout." |
| 70 | + fi |
| 71 | +fi |
| 72 | + |
| 73 | +cd bp |
| 74 | + |
| 75 | +# Version number replacements. |
| 76 | +# Version: x.y.z in bp-loader.php |
| 77 | +ver_regex='s/\(^ \* Version\:\s\+\)\([0-9\.]\+\)/\1'"$ver"/ |
| 78 | +sed -i "{$ver_regex}" bp-loader.php |
| 79 | +sed -i "{$ver_regex}" src/bp-loader.php |
| 80 | + |
| 81 | +# $this->version in bp-loader.php |
| 82 | +inline_ver_regex="s/\(\$this\->version\s\+= '\)[0-9\.]\+/\1""$ver"/ |
| 83 | +sed -i "{$inline_ver_regex}" src/bp-loader.php |
| 84 | + |
| 85 | +# Stable tag in readme.txt |
| 86 | +stable_regex='s/\(^Stable tag\:\s\+\)\([0-9\.]\+\)/\1'"$ver"/ |
| 87 | +sed -i "{$stable_regex}" src/readme.txt |
| 88 | + |
| 89 | +# Upgrade Notice and Changelog |
| 90 | +# Only add it if it hasn't already been added. |
| 91 | +already=$( grep -c "= $ver =" src/readme.txt ) |
| 92 | +if [ $already -eq 0 ]; then |
| 93 | + ver_hyphens="$(sed -e "s/\./-/g" <<< "$ver")" |
| 94 | + see="\n\n= $ver =\nSee: https:\/\/codex.buddypress.org\/releases\/version-$ver_hyphens\/" |
| 95 | + |
| 96 | + upgrade_regex='s/\(\(Upgrade Notice\|Changelog\).*\)/\1'"$see"/g |
| 97 | + sed -i "{$upgrade_regex}" src/readme.txt |
| 98 | + |
| 99 | + # $this->db_version in bp-loader.php should also only be updated when necessary. |
| 100 | + lastrev="$(svn log -l 1 http://buddypress.svn.wordpress.org | grep -oP "^r([0-9]+) \| ")" |
| 101 | + lastrev="$(sed -e "s/[^0-9]//g" <<< "$lastrev")" |
| 102 | + db_ver_regex="s/\(\$this\->db_version\s\+= \)[0-9\.]\+/\1""$lastrev"/ |
| 103 | + sed -i "{$db_ver_regex}" src/bp-loader.php |
| 104 | +fi |
| 105 | + |
| 106 | +echo "Version numbers bumped to $ver." |
| 107 | + |
| 108 | +# Commit version bumps. |
| 109 | +commit_message_bump="Bumping version numbers to $ver." |
| 110 | +if [ $dryrun -eq 0 ]; then |
| 111 | + read -n 1 -p "Ready to commit and tag in buddypress.svn.wordpress.org? (y/n)? " answer |
| 112 | + echo "" |
| 113 | + if [ "$answer" != 'y' ]; then |
| 114 | + echo "Are you yaller?" |
| 115 | + exit 1 |
| 116 | + fi |
| 117 | + svn ci -m "$commit_message_bump" |
| 118 | +else |
| 119 | + echo "DRY RUN: svn ci -m \"$commit_message_bump\"" |
| 120 | +fi |
| 121 | + |
| 122 | +# Create buddypress.svn.wordpress.org tag. |
| 123 | +commit_message_tag="Create tag $ver." |
| 124 | +echo "Creating tag." |
| 125 | +if [ $dryrun -eq 0 ]; then |
| 126 | + svn cp http://buddypress.svn.wordpress.org/branches/$branch http://buddypress.svn.wordpress.org/tags/$ver -m "$commit_message_tag" |
| 127 | +else |
| 128 | + echo "DRY RUN: svn cp http://buddypress.svn.wordpress.org/branches/$branch http://buddypress.svn.wordpress.org/tags/$ver -m \"$commit_message_tag\"" |
| 129 | +fi |
| 130 | + |
| 131 | +# Build the release. |
| 132 | +npm install |
| 133 | +grunt build # Not 'release', because we don't want bbPress. |
| 134 | + |
| 135 | +# Get a checkout of plugins.svn trunk. |
| 136 | +cd .. |
| 137 | + |
| 138 | +if [ $use_existing_checkouts -eq 0 ]; then |
| 139 | + # Remove existing wporg working directory. |
| 140 | + if [ -d "wporg" ]; then |
| 141 | + rm -rf ./wporg |
| 142 | + fi |
| 143 | + |
| 144 | + svn co --ignore-externals http://plugins.svn.wordpress.org/buddypress/trunk wporg |
| 145 | +fi |
| 146 | + |
| 147 | +# Sync the changes from the bporg checkout to the wporg checkout. |
| 148 | +rsync -r --exclude='.svn' bp/src/ wporg/ |
| 149 | + |
| 150 | +# Remove bbPress from the checkout and set the external (should already be done, but just in case). |
| 151 | +cd wporg |
| 152 | +rm -rf bp-forums/bbpress |
| 153 | +svn propset svn:externals 'bbpress https://bbpress.svn.wordpress.org/tags/1.2/' bp-forums |
| 154 | + |
| 155 | +# Before committing, roll back the readme, so that the stable tag is not changed. |
| 156 | +svn diff readme.txt > ../readme.diff |
| 157 | +svn revert readme.txt |
| 158 | +svn status |
| 159 | + |
| 160 | +# Commit to trunk. |
| 161 | +echo '' |
| 162 | +echo "Committing to plugins.svn.wordpress.org trunk." |
| 163 | +if [ $dryrun -eq 0 ]; then |
| 164 | + read -n 1 -p "Ready to commit and tag? (y/n)? " answer |
| 165 | + echo "" |
| 166 | + if [ "$answer" != 'y' ]; then |
| 167 | + echo "Boo hoo" |
| 168 | + exit 1 |
| 169 | + fi |
| 170 | + svn ci -m "Sync to plugins.svn.wordpress.org for $ver release." |
| 171 | +else |
| 172 | + echo "DRY RUN: svn ci -m \"Sync to plugins.svn.wordpress.org for $ver release.\"" |
| 173 | +fi |
| 174 | + |
| 175 | +# svn cp to the new tag |
| 176 | +# Create buddypress.svn.wordpress.org tag. |
| 177 | +commit_message_tag="Create tag $ver." |
| 178 | +echo "Creating tag." |
| 179 | +if [ $dryrun -eq 0 ]; then |
| 180 | + svn cp http://plugins.svn.wordpress.org/buddypress/trunk http://plugins.svn.wordpress.org/buddypress/tags/$ver -m "$commit_message_tag" |
| 181 | +else |
| 182 | + echo "DRY RUN: svn cp http://plugins.svn.wordpress.org/buddypres/trunk http://plugins.svn.wordpress.org/tags/$ver -m \"$commit_message_tag\"" |
| 183 | +fi |
| 184 | + |
| 185 | +# Then bump stable tag in trunk |
| 186 | +echo "One more step: Bump the stable tag in readme.txt." |
| 187 | +patch -p0 < ../readme.diff |
| 188 | + |
| 189 | +if [ $dryrun -eq 0 ]; then |
| 190 | + read -n 1 -p "Shall I do the honors? (y/n)? " answer |
| 191 | + echo "" |
| 192 | + if [ "$answer" != 'y' ]; then |
| 193 | + echo "Don't forget to do it yourself" |
| 194 | + exit 1 |
| 195 | + fi |
| 196 | + svn ci -m "Bump stable tag to $ver." |
| 197 | +else |
| 198 | + echo "DRY RUN: svn ci -m \"Bump stable tag to $ver.\"" |
| 199 | +fi |
0 commit comments