33set -euo pipefail
44
55# Deploy script for Ultimate Multisite
6- # Usage: bin/deploy.sh 2.4.6
6+ # Usage: bin/deploy.sh 2.4.6 (stable release)
7+ # bin/deploy.sh 2.4.6-beta.1 (pre-release)
78#
89# This script:
9- # 1) Updates versions in readme.txt, plugin header, WP_Ultimo::VERSION, composer.json, package.json
10- # 2) Ensures changelog entry exists; replaces XX-XX date; syncs entry into README.md Recent Changes
10+ # 1) Updates versions in plugin header, WP_Ultimo::VERSION, composer.json, package.json
11+ # (and readme.txt Stable tag for stable releases only)
12+ # 2) For stable releases: ensures changelog entry exists; replaces XX-XX date; syncs to README.md
13+ # For pre-releases: skips changelog sync
1114# 3) Commits and pushes to main
1215# 4) Runs npm build to generate ultimate-multisite.zip
1316# 5) Tags and creates a GitHub release, attaching the ZIP and including changelog + PR log
14- # 6) Deploys to WordPress.org SVN trunk and tags/<version>
17+ # 6) For stable releases only: deploys to WordPress.org SVN trunk and tags/<version>
18+ #
19+ # Pre-release suffixes: alpha, beta, rc, dev, preview (e.g. 2.4.6-beta.1)
1520#
1621# Requirements:
1722# - Run from repository root or anywhere; script will cd into ultimate-multisite directory automatically
@@ -42,14 +47,28 @@ cd "$PLUGIN_DIR"
4247VERSION=" ${1:- } "
4348if [[ -z " $VERSION " ]]; then
4449 echo " Usage: $( basename " $0 " ) <version>"
50+ echo " $( basename " $0 " ) <version>-beta.1"
51+ echo " "
52+ echo " Pre-release versions (alpha, beta, rc, dev, preview) skip:"
53+ echo " - readme.txt Stable tag update"
54+ echo " - Changelog date replacement and README.md sync"
55+ echo " - WordPress.org SVN deployment"
4556 exit 1
4657fi
4758
48- if [[ ! " $VERSION " =~ ^[0-9]+\. [0-9]+\. [0-9]+$ ]]; then
49- echo " Error: Version must be in form X.Y.Z (e.g., 2.4.6)"
59+ if [[ ! " $VERSION " =~ ^[0-9]+\. [0-9]+\. [0-9]+ (-(alpha | beta | rc | dev | preview) \. [0-9]+) ? $ ]]; then
60+ echo " Error: Version must be in form X.Y.Z or X.Y.Z-beta.N (e.g., 2.4.6 or 2.4.6-beta.1 )"
5061 exit 1
5162fi
5263
64+ # Detect pre-release versions
65+ IS_PRERELEASE=false
66+ if [[ " $VERSION " =~ -(alpha| beta| rc| dev| preview)\. ]]; then
67+ IS_PRERELEASE=true
68+ echo " ==> Pre-release detected: $VERSION "
69+ echo " Skipping: readme.txt Stable tag, changelog sync, WordPress.org SVN"
70+ fi
71+
5372DATE_TODAY=$( date +%Y-%m-%d)
5473SVN_SLUG=${WPORG_SLUG:- ultimate-multisite}
5574ZIP_NAME=" ultimate-multisite.zip"
@@ -89,8 +108,13 @@ ensure_clean_git() {
89108update_versions () {
90109 echo " ==> Updating versions to $VERSION "
91110
92- # readme.txt Stable tag
93- sed -i.bak -E " s/^(Stable tag:[[:space:]]*).*/\\ 1$VERSION /" readme.txt
111+ # readme.txt Stable tag (skip for pre-releases)
112+ if [[ " $IS_PRERELEASE " == " false" ]]; then
113+ sed -i.bak -E " s/^(Stable tag:[[:space:]]*).*/\\ 1$VERSION /" readme.txt
114+ rm -f readme.txt.bak
115+ else
116+ echo " Skipping readme.txt Stable tag (pre-release)"
117+ fi
94118
95119 # ultimate-multisite.php header Version and @version
96120 sed -i.bak -E " s/^( \* Version:[[:space:]]*).*/\\ 1$VERSION /" ultimate-multisite.php
@@ -109,6 +133,11 @@ update_versions() {
109133}
110134
111135sync_changelog_and_date () {
136+ if [[ " $IS_PRERELEASE " == " true" ]]; then
137+ echo " ==> Skipping changelog sync (pre-release)"
138+ return
139+ fi
140+
112141 echo " ==> Updating changelog date and syncing to README.md"
113142
114143 # Ensure changelog entry exists and replace XX-XX with today's date
@@ -163,7 +192,11 @@ sync_changelog_and_date() {
163192
164193commit_and_push () {
165194 echo " ==> Committing and pushing changes to main"
166- git add readme.txt README.md ultimate-multisite.php inc/class-wp-ultimo.php composer.json package.json
195+ if [[ " $IS_PRERELEASE " == " true" ]]; then
196+ git add ultimate-multisite.php inc/class-wp-ultimo.php composer.json package.json
197+ else
198+ git add readme.txt README.md ultimate-multisite.php inc/class-wp-ultimo.php composer.json package.json
199+ fi
167200 git commit -m " chore(release): v$VERSION " || true
168201 git push origin main
169202}
@@ -205,12 +238,18 @@ generate_release_notes() {
205238 fi
206239
207240 RELEASE_NOTES_FILE=$( mktemp)
241+ # For pre-releases, use the base version (X.Y.Z) to find changelog entries
242+ local changelog_ver=" $VERSION "
243+ if [[ " $IS_PRERELEASE " == " true" ]]; then
244+ changelog_ver=" ${VERSION%% -* } "
245+ fi
246+
208247 {
209248 echo " ## Release v$VERSION "
210249 echo
211250 echo " ### Highlights"
212251 # Take the bullet lines from the readme.txt changelog block
213- awk -v ver=" $VERSION " '
252+ awk -v ver=" $changelog_ver " '
214253 $0 ~ ("^Version [[]" ver "[]] - Released on") { on=1; next }
215254 on {
216255 if ($0 ~ /^Version [[]/) exit
@@ -249,9 +288,14 @@ tag_and_github_release() {
249288 gh release edit " v$VERSION " --notes-file " $RELEASE_NOTES_FILE " || true
250289 gh release upload " v$VERSION " " $ZIP_PATH " --clobber || true
251290 else
291+ local prerelease_flag=" "
292+ if [[ " $IS_PRERELEASE " == " true" ]]; then
293+ prerelease_flag=" --prerelease"
294+ fi
252295 gh release create " v$VERSION " " $ZIP_PATH " \
253296 --title " v$VERSION " \
254- --notes-file " $RELEASE_NOTES_FILE "
297+ --notes-file " $RELEASE_NOTES_FILE " \
298+ $prerelease_flag
255299 fi
256300 else
257301 echo " Skipping GitHub release step: 'gh' missing or GH_TOKEN not set."
@@ -316,8 +360,13 @@ main() {
316360 build_zip
317361 generate_release_notes
318362 tag_and_github_release
319- deploy_to_wporg_svn
320- echo " \n✅ Deployment of v$VERSION completed."
363+ if [[ " $IS_PRERELEASE " == " false" ]]; then
364+ deploy_to_wporg_svn
365+ else
366+ echo " ==> Skipping WordPress.org SVN deployment (pre-release)"
367+ fi
368+ echo " "
369+ echo " ✅ Deployment of v$VERSION completed."
321370}
322371
323372main " $@ "
0 commit comments