Skip to content

Commit 6608e2b

Browse files
authored
Internal: Update wordpress deployment scripts [TMZ-803] (#573)
1 parent 9a01d32 commit 6608e2b

File tree

3 files changed

+151
-126
lines changed

3 files changed

+151
-126
lines changed
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
#!/bin/bash
2+
set -eo pipefail
3+
4+
echo "🧪 DRY RUN MODE: Will simulate SVN operations without committing"
5+
6+
if [[ -z "$THEME_VERSION" ]]; then
7+
echo "Set the THEME_VERSION env var"
8+
exit 1
9+
fi
10+
11+
if [[ -z "$THEME_SLUG" ]]; then
12+
echo "Set the THEME_SLUG env var"
13+
exit 1
14+
fi
15+
16+
if [[ -z "$BUILD_DIR" ]]; then
17+
echo "Set the BUILD_DIR env var"
18+
exit 1
19+
fi
20+
21+
# Ensure SVN is installed
22+
svn --version
23+
24+
echo "SVN installed"
25+
26+
echo "Publish theme version: ${THEME_VERSION}"
27+
echo "Theme slug: ${THEME_SLUG}"
28+
echo "Build directory: ${BUILD_DIR}"
29+
30+
THEME_PATH="$GITHUB_WORKSPACE"
31+
SVN_PATH="$GITHUB_WORKSPACE/svn"
32+
VERSION_DIR="${THEME_VERSION}"
33+
34+
cd $THEME_PATH
35+
pwd
36+
mkdir -p $SVN_PATH
37+
cd $SVN_PATH
38+
39+
echo "🧪 DRY RUN: Checking out SVN repository (read-only)"
40+
svn co --depth immediates "https://themes.svn.wordpress.org/${THEME_SLUG}" . 2>&1 | head -20 || {
41+
echo "⚠️ Could not checkout repository (may require auth for some operations)"
42+
echo " This is normal - simulating checkout for dry-run"
43+
mkdir -p "$VERSION_DIR"
44+
cd "$VERSION_DIR"
45+
}
46+
47+
echo "Check if version folder already exists"
48+
VERSION_EXISTS=false
49+
if svn list "https://themes.svn.wordpress.org/${THEME_SLUG}/${VERSION_DIR}" > /dev/null 2>&1; then
50+
VERSION_EXISTS=true
51+
fi
52+
53+
if [[ "$VERSION_EXISTS" == "true" ]]; then
54+
echo "❌ ERROR: Version folder $VERSION_DIR already exists in SVN!
55+
SVN URL: https://themes.svn.wordpress.org/${THEME_SLUG}/${VERSION_DIR}
56+
57+
WordPress.org theme versions are immutable - you cannot update an existing version.
58+
If you need to make changes, create a new version (e.g., increment patch/minor/major).
59+
60+
🧪 DRY RUN: Would fail here (version already exists)"
61+
exit 0
62+
fi
63+
64+
mkdir -p "$VERSION_DIR"
65+
cd "$VERSION_DIR"
66+
67+
echo "Copy files from build directory"
68+
rsync -ah --progress "$THEME_PATH/$BUILD_DIR/"* . || rsync -ah --progress "$THEME_PATH/$BUILD_DIR/." . || true
69+
70+
echo "Preparing files for SVN"
71+
svn status 2>/dev/null || echo ""
72+
73+
echo "svn add new files"
74+
echo "🧪 DRY RUN: Would add new files"
75+
svn status 2>/dev/null | grep -v '^.[ \t]*\\..*' | { grep '^?' || true; } | awk '{print $2}' | sed 's|^| Would add: |' || true
76+
77+
echo ""
78+
echo "📊 **SVN Status Summary (what would be committed):**"
79+
echo "=========================================="
80+
SVN_STATUS=$(svn status 2>/dev/null || echo "")
81+
TOTAL_CHANGES=0
82+
if [ -n "$SVN_STATUS" ]; then
83+
echo "$SVN_STATUS"
84+
echo ""
85+
echo "Summary:"
86+
ADDED_COUNT=$(echo "$SVN_STATUS" | grep -c "^A" || echo "0")
87+
MODIFIED_COUNT=$(echo "$SVN_STATUS" | grep -c "^M" || echo "0")
88+
UNTRACKED_COUNT=$(echo "$SVN_STATUS" | grep -c "^?" || echo "0")
89+
90+
echo " Added (A): $ADDED_COUNT files"
91+
if [ "$MODIFIED_COUNT" -gt 0 ]; then
92+
echo " Modified (M): $MODIFIED_COUNT files"
93+
fi
94+
if [ "$UNTRACKED_COUNT" -gt 0 ]; then
95+
echo " ⚠️ Untracked (?): $UNTRACKED_COUNT files (would be added)"
96+
fi
97+
echo ""
98+
TOTAL_CHANGES=$((ADDED_COUNT + MODIFIED_COUNT))
99+
echo " Total files that would be committed: $TOTAL_CHANGES files"
100+
else
101+
echo " (No changes detected - files are up to date)"
102+
fi
103+
echo "=========================================="
104+
echo ""
105+
106+
if [ "$TOTAL_CHANGES" -gt 0 ]; then
107+
echo "🧪 DRY RUN: Would commit $TOTAL_CHANGES files to version folder $VERSION_DIR"
108+
echo " Commit message: Upload v${THEME_VERSION}"
109+
else
110+
echo "🧪 DRY RUN: No changes to commit (files are up to date)"
111+
fi
112+
echo " 🚫 No actual commit performed (dry-run mode)"
113+
114+
echo "Remove the SVN folder from the workspace"
115+
rm -rf $SVN_PATH
116+
117+
echo "Back to the workspace root"
118+
cd $GITHUB_WORKSPACE
119+
120+
echo "✅ Dry-run complete: v${THEME_VERSION}"
121+
echo " All checks passed - ready for actual deployment"
122+
Lines changed: 28 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,14 @@
11
#!/bin/bash
22
set -eo pipefail
33

4-
DRY_RUN=false
5-
if [[ "$1" == "--dry-run" ]]; then
6-
DRY_RUN=true
7-
echo "🧪 DRY RUN MODE: Will simulate SVN operations without committing"
4+
if [[ -z "$SVN_USERNAME" ]]; then
5+
echo "Set the SVN_USERNAME secret"
6+
exit 1
87
fi
98

10-
if [[ "$DRY_RUN" == "false" ]]; then
11-
if [[ -z "$SVN_USERNAME" ]]; then
12-
echo "Set the SVN_USERNAME secret"
13-
exit 1
14-
fi
15-
16-
if [[ -z "$SVN_PASSWORD" ]]; then
17-
echo "Set the SVN_PASSWORD secret"
18-
exit 1
19-
fi
9+
if [[ -z "$SVN_PASSWORD" ]]; then
10+
echo "Set the SVN_PASSWORD secret"
11+
exit 1
2012
fi
2113

2214
if [[ -z "$THEME_VERSION" ]]; then
@@ -34,139 +26,57 @@ if [[ -z "$BUILD_DIR" ]]; then
3426
exit 1
3527
fi
3628

29+
# Ensure SVN is installed
3730
svn --version
3831

3932
echo "SVN installed"
4033

4134
echo "Publish theme version: ${THEME_VERSION}"
42-
echo "Theme slug: ${THEME_SLUG}"
43-
echo "Build directory: ${BUILD_DIR}"
4435

4536
THEME_PATH="$GITHUB_WORKSPACE"
4637
SVN_PATH="$GITHUB_WORKSPACE/svn"
47-
SVN_URL="https://themes.svn.wordpress.org/${THEME_SLUG}"
4838
VERSION_DIR="${THEME_VERSION}"
4939

5040
cd $THEME_PATH
5141
pwd
5242
mkdir -p $SVN_PATH
5343
cd $SVN_PATH
5444

55-
echo "Checkout SVN repository root"
56-
if [[ "$DRY_RUN" == "true" ]]; then
57-
echo "🧪 DRY RUN: Checking out SVN repository (read-only)"
58-
svn co --depth immediates "$SVN_URL" . 2>&1 | head -20 || {
59-
echo "⚠️ Could not checkout repository (may require auth for some operations)"
60-
echo " This is normal - simulating checkout for dry-run"
61-
mkdir -p "$VERSION_DIR"
62-
cd "$VERSION_DIR"
63-
}
64-
else
65-
svn co --depth immediates "$SVN_URL" .
66-
fi
45+
echo "Checkout from SVN"
46+
svn co --depth immediates "https://themes.svn.wordpress.org/${THEME_SLUG}" .
6747

6848
echo "Check if version folder already exists"
69-
VERSION_EXISTS=false
70-
if svn list "$SVN_URL/$VERSION_DIR" > /dev/null 2>&1; then
71-
VERSION_EXISTS=true
72-
fi
49+
if svn list "https://themes.svn.wordpress.org/${THEME_SLUG}/${VERSION_DIR}" > /dev/null 2>&1; then
50+
echo "❌ ERROR: Version folder $VERSION_DIR already exists in SVN!
51+
SVN URL: https://themes.svn.wordpress.org/${THEME_SLUG}/${VERSION_DIR}
7352
74-
if [[ "$VERSION_EXISTS" == "true" ]]; then
75-
echo "❌ ERROR: Version folder $VERSION_DIR already exists in SVN!"
76-
echo " SVN URL: $SVN_URL/$VERSION_DIR"
77-
echo ""
78-
echo " WordPress.org theme versions are immutable - you cannot update an existing version."
79-
echo " If you need to make changes, create a new version (e.g., increment patch/minor/major)."
80-
echo ""
81-
if [[ "$DRY_RUN" == "true" ]]; then
82-
echo "🧪 DRY RUN: Would fail here (version already exists)"
83-
else
84-
exit 1
85-
fi
53+
WordPress.org theme versions are immutable - you cannot update an existing version.
54+
If you need to make changes, create a new version (e.g., increment patch/minor/major)."
55+
exit 1
8656
fi
8757

88-
echo "Version folder $VERSION_DIR does not exist - will create it"
8958
mkdir -p "$VERSION_DIR"
9059
cd "$VERSION_DIR"
91-
if [[ "$DRY_RUN" == "false" ]]; then
92-
cd ..
93-
svn add "$VERSION_DIR"
94-
cd "$VERSION_DIR"
95-
fi
60+
cd ..
61+
svn add "$VERSION_DIR"
62+
cd "$VERSION_DIR"
9663

97-
echo "Copy files from build directory"
98-
if [[ "$BUILD_DIR" == /* ]]; then
99-
BUILD_SOURCE="$BUILD_DIR"
100-
else
101-
BUILD_SOURCE="$THEME_PATH/$BUILD_DIR"
102-
fi
64+
echo "Copy files"
65+
rsync -ah --progress "$THEME_PATH/$BUILD_DIR/"* . || rsync -ah --progress "$THEME_PATH/$BUILD_DIR/." . || true
10366

104-
if [ ! -d "$BUILD_SOURCE" ]; then
105-
echo "❌ Build directory not found: $BUILD_SOURCE"
106-
exit 1
107-
fi
67+
echo "Preparing files"
68+
cd "$VERSION_DIR"
10869

109-
rsync -ah --progress "$BUILD_SOURCE/"* . || rsync -ah --progress "$BUILD_SOURCE/." . || true
70+
echo "svn add"
71+
svn status | grep -v '^.[ \t]*\\..*' | { grep '^?' || true; } | awk '{print $2}' | xargs -r svn add || true
11072

111-
echo "Preparing files for SVN"
11273
svn status
11374

114-
echo "svn add new files"
115-
if [[ "$DRY_RUN" == "false" ]]; then
116-
svn status | grep -v '^.[ \t]*\\..*' | { grep '^?' || true; } | awk '{print $2}' | xargs -r svn add || true
117-
else
118-
echo "🧪 DRY RUN: Would add new files"
119-
svn status 2>/dev/null | grep -v '^.[ \t]*\\..*' | { grep '^?' || true; } | awk '{print $2}' | sed 's|^| Would add: |' || true
120-
fi
75+
echo "Commit files to version folder $VERSION_DIR"
76+
svn ci -m "Upload v${THEME_VERSION}" --no-auth-cache --non-interactive --username "$SVN_USERNAME" --password "$SVN_PASSWORD"
12177

122-
echo ""
123-
echo "📊 **SVN Status Summary (what will be committed):**"
124-
echo "=========================================="
125-
SVN_STATUS=$(svn status 2>/dev/null || echo "")
126-
TOTAL_CHANGES=0
127-
if [ -n "$SVN_STATUS" ]; then
128-
echo "$SVN_STATUS"
129-
echo ""
130-
echo "Summary:"
131-
ADDED_COUNT=$(echo "$SVN_STATUS" | grep -c "^A" || echo "0")
132-
MODIFIED_COUNT=$(echo "$SVN_STATUS" | grep -c "^M" || echo "0")
133-
UNTRACKED_COUNT=$(echo "$SVN_STATUS" | grep -c "^?" || echo "0")
134-
135-
echo " Added (A): $ADDED_COUNT files"
136-
if [ "$MODIFIED_COUNT" -gt 0 ]; then
137-
echo " Modified (M): $MODIFIED_COUNT files"
138-
fi
139-
if [ "$UNTRACKED_COUNT" -gt 0 ]; then
140-
echo " ⚠️ Untracked (?): $UNTRACKED_COUNT files (will be ignored)"
141-
fi
142-
echo ""
143-
TOTAL_CHANGES=$((ADDED_COUNT + MODIFIED_COUNT))
144-
echo " Total files to commit: $TOTAL_CHANGES files"
145-
else
146-
echo " (No changes detected - files are up to date)"
147-
fi
148-
echo "=========================================="
149-
echo ""
150-
151-
if [[ "$DRY_RUN" == "true" ]]; then
152-
if [ "$TOTAL_CHANGES" -gt 0 ]; then
153-
echo "🧪 DRY RUN: Would commit $TOTAL_CHANGES files to version folder $VERSION_DIR"
154-
echo " Commit message: Upload v${THEME_VERSION}"
155-
else
156-
echo "🧪 DRY RUN: No changes to commit (files are up to date)"
157-
fi
158-
echo " 🚫 No actual commit performed (dry-run mode)"
159-
else
160-
if [ "$TOTAL_CHANGES" -gt 0 ]; then
161-
echo "Commit files to version folder $VERSION_DIR"
162-
svn ci -m "Upload v${THEME_VERSION}" --no-auth-cache --non-interactive --username "$SVN_USERNAME" --password "$SVN_PASSWORD"
163-
164-
cd $SVN_PATH
165-
svn update
166-
else
167-
echo "⚠️ No changes to commit - files are already up to date"
168-
fi
169-
fi
78+
cd $SVN_PATH
79+
svn update
17080

17181
echo "Remove the SVN folder from the workspace"
17282
rm -rf $SVN_PATH
@@ -175,4 +85,3 @@ echo "Back to the workspace root"
17585
cd $GITHUB_WORKSPACE
17686

17787
echo "Theme deployment complete: v${THEME_VERSION}"
178-

.github/workflows/release.yml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -313,13 +313,7 @@ jobs:
313313
THEME_SLUG: ${{ env.CONFIG_THEME_SLUG }}
314314
BUILD_DIR: ${{ env.BUILD_DIR }}
315315
run: |
316-
echo "🧪 DRY RUN: Executing deployment script in dry-run mode"
317-
echo " - Theme slug: ${{ env.CONFIG_THEME_SLUG }}"
318-
echo " - Version: ${{ env.PACKAGE_VERSION }}"
319-
echo " - Build directory: ${{ env.BUILD_DIR }}"
320-
echo " - SVN URL: https://themes.svn.wordpress.org/${{ env.CONFIG_THEME_SLUG }}"
321-
echo ""
322-
bash .github/scripts/publish-theme-to-wordpress-org.sh --dry-run
316+
bash .github/scripts/publish-theme-to-wordpress-org-dry-run.sh
323317
324318
- name: Show SVN Status (Dry Run)
325319
if: ${{ inputs.dry_run == true && inputs.deploy_to_wporg == true && env.AUTO_DEPLOY_ENABLED == 'true' }}

0 commit comments

Comments
 (0)