Skip to content

fix(ci): install subversion before SVN deploy step #29

fix(ci): install subversion before SVN deploy step

fix(ci): install subversion before SVN deploy step #29

Workflow file for this run

name: Release WordPress Plugin
on:
push:
tags:
- 'v*.*.*'
permissions:
contents: write
jobs:
build:
name: Build and Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
fetch-depth: 0
- name: Setup PHP
uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # v2
with:
php-version: '7.4'
extensions: mbstring, intl, curl
tools: composer, wp-cli
- name: Get the version
id: get_version
run: |
VERSION="${GITHUB_REF#refs/tags/v}"
echo "VERSION=$VERSION" >> $GITHUB_ENV
case "$VERSION" in
*-alpha*|*-beta*|*-rc*|*-dev*|*-preview*)
echo "IS_PRERELEASE=true" >> $GITHUB_ENV
;;
*)
echo "IS_PRERELEASE=false" >> $GITHUB_ENV
;;
esac
- name: Set up Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: '20'
cache: 'npm'
- name: Install PHP dependencies
run: composer install
- name: Install Node dependencies
run: npm ci
- name: Verify version matches
run: |
WP_VERSION=$(grep -m 1 " \* Version:" ultimate-multisite.php | sed 's/.*Version:[[:space:]]*//')
README_VERSION=$(grep -m 1 "Stable tag: " readme.txt | awk -F' ' '{print $3}')
PKG_VERSION=$(node -p "require('./package.json').version")
echo "Tag version: ${{ env.VERSION }}"
echo "Plugin version: $WP_VERSION"
echo "readme.txt version: $README_VERSION"
echo "package.json version: $PKG_VERSION"
# For pre-releases, only check plugin header and package.json
# (readme.txt Stable tag stays at the last stable version)
if [ "${{ env.IS_PRERELEASE }}" = "true" ]; then
if [ "$WP_VERSION" != "${{ env.VERSION }}" ] || [ "$PKG_VERSION" != "${{ env.VERSION }}" ]; then
echo "Error: Version mismatch detected!"
exit 1
fi
echo "Pre-release version numbers match: ${{ env.VERSION }}"
else
if [ "$WP_VERSION" != "${{ env.VERSION }}" ] || [ "$README_VERSION" != "${{ env.VERSION }}" ] || [ "$PKG_VERSION" != "${{ env.VERSION }}" ]; then
echo "Error: Version mismatch detected!"
exit 1
fi
echo "All version numbers match: ${{ env.VERSION }}"
fi
- name: Run build process
run: npm run build
env:
MU_CLIENT_ID: ${{ secrets.MU_CLIENT_ID }}
MU_CLIENT_SECRET: ${{ secrets.MU_CLIENT_SECRET }}
- name: Rename archive for release
run: |
mkdir -p build
mv ultimate-multisite.zip build/ultimate-multisite-${{ env.VERSION }}.zip
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: ultimate-multisite-zip
path: build/ultimate-multisite-${{ env.VERSION }}.zip
retention-days: 7
- name: Create Release
id: create_release
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1
with:
files: |
build/ultimate-multisite-${{ env.VERSION }}.zip
name: Ultimate Multisite ${{ env.VERSION }}
draft: true
prerelease: ${{ env.IS_PRERELEASE == 'true' }}
body: |
# Ultimate Multisite ${{ env.VERSION }}
## What's Changed
For a complete list of changes, please refer to the [changelog](https://github.com/Multisite-Ultimate/ultimate-multisite/blob/main/readme.txt).
## Installation
1. Download the ZIP file from this release
2. Upload and activate the plugin in your WordPress Network installation
3. Follow the setup wizard to configure the plugin
## Notes
- Compatible with WordPress 5.3+
- Requires PHP 7.4.30+
- Always backup your site before upgrading
deploy-to-wporg:
name: Deploy to WordPress.org
runs-on: ubuntu-latest
needs: build
# Only deploy stable releases to wp.org (skip pre-releases)
if: ${{ !contains(github.ref, '-alpha') && !contains(github.ref, '-beta') && !contains(github.ref, '-rc') && !contains(github.ref, '-dev') && !contains(github.ref, '-preview') }}
steps:
- name: Checkout code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
fetch-depth: 0
- name: Get the version
run: |
VERSION="${GITHUB_REF#refs/tags/v}"
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: ultimate-multisite-zip
path: build/
- name: Unzip build artifact into workspace
run: |
unzip -o build/ultimate-multisite-${{ env.VERSION }}.zip -d .
- name: Install SVN
run: sudo apt-get update && sudo apt-get install -y subversion
- name: Deploy to WordPress.org SVN (shallow)
env:
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
SLUG: ultimate-multisite
VERSION: ${{ env.VERSION }}
run: |
set -euo pipefail
SVN_URL="https://plugins.svn.wordpress.org/${SLUG}"
SVN_DIR="${HOME}/svn-${SLUG}"
# Shallow checkout: only trunk and assets (no tags history)
svn checkout --depth=immediates "${SVN_URL}" "${SVN_DIR}"
svn update --set-depth=infinity "${SVN_DIR}/trunk"
svn update --set-depth=immediates "${SVN_DIR}/tags"
# If assets dir exists in SVN, pull it too
if svn info "${SVN_URL}/assets" > /dev/null 2>&1; then
svn update --set-depth=infinity "${SVN_DIR}/assets"
fi
# Sync build artifact into trunk (the unzipped plugin files are in ./ultimate-multisite/)
rsync -rc --delete ./ultimate-multisite/ "${SVN_DIR}/trunk/" \
--exclude='.svn' --exclude='.git' --exclude='.github'
# Create the new tag from trunk
if svn info "${SVN_URL}/tags/${VERSION}" > /dev/null 2>&1; then
echo "Tag ${VERSION} already exists in SVN — skipping tag creation"
else
svn copy "${SVN_DIR}/trunk" "${SVN_DIR}/tags/${VERSION}"
fi
# Copy readme.txt to trunk for wp.org metadata
cp readme.txt "${SVN_DIR}/trunk/readme.txt"
# Stage all changes
cd "${SVN_DIR}"
svn add --force . --auto-props --parents --depth infinity -q 2>/dev/null || true
# Remove deleted files from SVN tracking
svn status | grep '^\!' | awk '{print $2}' | xargs -r svn delete --force -q
# Show what will be committed
echo "=== SVN Status ==="
svn status | head -50
CHANGES=$(svn status | wc -l)
echo "Total changes: ${CHANGES}"
if [ "${CHANGES}" -eq 0 ]; then
echo "No changes to commit to WordPress.org SVN"
exit 0
fi
# Commit with timeout-friendly settings
svn commit \
--username "${SVN_USERNAME}" \
--password "${SVN_PASSWORD}" \
--no-auth-cache \
--non-interactive \
-m "Release ${VERSION}"
echo "Successfully deployed ${VERSION} to WordPress.org"