Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/actions/deploy-to-wordpress/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ This GitHub Action deploys a WordPress plugin to the WordPress.org marketplace v
test-mode: false
```

**Note**: For test mode, use `TEST_SVN_USERNAME` and `TEST_SVN_PASSWORD` secrets instead.

### Testing with dry-run

```yaml
Expand All @@ -40,6 +42,8 @@ Add these secrets to your repository:
- `TEST_SVN_USERNAME`: Your test SVN username (optional, for test mode)
- `TEST_SVN_PASSWORD`: Your test SVN password (optional, for test mode)

**Note**: The workflows handle credential selection automatically based on the `test-mode` input.

### Required GitHub Variables

Add these variables to your repository (Settings > Secrets and variables > Actions > Variables):
Expand Down Expand Up @@ -71,9 +75,10 @@ Add these variables to your repository (Settings > Secrets and variables > Actio
- Standard commit messages

### Test Mode
- Uses test SVN credentials (if provided) or defaults
- Uses test SVN credentials (if provided) or default test credentials
- Marks commits with "TEST:" prefix
- Safe for testing without affecting production
- If test credentials are not set, uses default test values

### Dry Run Mode
- No SVN operations performed
Expand Down
12 changes: 3 additions & 9 deletions .github/actions/deploy-to-wordpress/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ runs:
steps:
- name: Checkout code
uses: actions/checkout@v4
shell: bash

- name: Deploy to WordPress Marketplace
run: |
Expand All @@ -56,14 +55,9 @@ runs:
export DRY_RUN="${{ inputs.dry-run }}"
export TEST_MODE="${{ inputs.test-mode }}"

# Set SVN credentials based on mode
if [ "${{ inputs.test-mode }}" = "true" ]; then
export SVN_USERNAME="${{ secrets.TEST_SVN_USERNAME || 'test-user' }}"
export SVN_PASSWORD="${{ secrets.TEST_SVN_PASSWORD || 'test-pass' }}"
else
export SVN_USERNAME="${{ inputs.svn-username }}"
export SVN_PASSWORD="${{ inputs.svn-password }}"
fi
# Set SVN credentials
export SVN_USERNAME="${{ inputs.svn-username }}"
export SVN_PASSWORD="${{ inputs.svn-password }}"

# Run deployment script
.github/actions/deploy-to-wordpress/scripts/deploy.sh
Expand Down
41 changes: 34 additions & 7 deletions .github/actions/deploy-to-wordpress/scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ validate_inputs() {
exit 1
fi

# Set default test credentials if in test mode and credentials are empty
if is_test_mode && [ -z "$SVN_USERNAME" ]; then
print_status $YELLOW "Warning: TEST_SVN_USERNAME not set, using default test credentials"
export SVN_USERNAME="test-user"
fi

if is_test_mode && [ -z "$SVN_PASSWORD" ]; then
print_status $YELLOW "Warning: TEST_SVN_PASSWORD not set, using default test credentials"
export SVN_PASSWORD="test-pass"
fi

if ! is_dry_run && [ -z "$SVN_USERNAME" ]; then
print_status $RED "Error: SVN_USERNAME is required when not in dry-run mode"
exit 1
Expand All @@ -62,6 +73,9 @@ setup_environment() {
sudo apt-get update
sudo apt-get install -y subversion
fi

# Check SVN version and capabilities
print_status $YELLOW "SVN version: $(svn --version --quiet)"
fi
}

Expand Down Expand Up @@ -145,26 +159,39 @@ handle_svn_operations() {
cp -r "$ASSETS_DIR"/* svn-repo/assets/
fi

# Create version tag
print_status $YELLOW "Creating version tag..."
svn copy svn-repo/trunk svn-repo/tags/$VERSION -m "Tagging version $VERSION"

# Add new files to SVN
# Add new files to SVN first (before creating tag)
print_status $YELLOW "Adding files to SVN..."
cd svn-repo
svn add --force trunk/*
svn add --force tags/$VERSION/*

# Add trunk files with error handling
print_status $YELLOW "Adding trunk files..."
svn add --force trunk/* 2>/dev/null || true

# Add assets if they exist
if [ -d "assets" ]; then
print_status $YELLOW "Adding assets..."
svn add --force assets/* 2>/dev/null || true
fi

# Create version tag (after adding files to trunk)
print_status $YELLOW "Creating version tag..."
svn copy trunk tags/$VERSION

# Add files in the new tag
print_status $YELLOW "Adding tag files..."
svn add --force tags/$VERSION/* 2>/dev/null || true

# Commit changes to SVN
print_status $YELLOW "Committing changes to SVN..."
local commit_message="Deploy version $VERSION"
if is_test_mode; then
commit_message="TEST: $commit_message"
fi

# Show status before commit
print_status $YELLOW "SVN status before commit:"
svn status

svn commit -m "$commit_message" --username "$SVN_USERNAME" --password "$SVN_PASSWORD" --non-interactive --trust-server-cert

cd ..
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/deploy-wordpress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
version:
description: 'Plugin version to deploy'
required: true
default: '2.0.8'
default: ''
dry-run:
description: 'Perform dry run (no actual deployment)'
required: false
Expand Down Expand Up @@ -37,8 +37,8 @@ jobs:
with:
version: ${{ github.event.inputs.version || github.ref_name }}
plugin-slug: ${{ vars.WP_PLUGIN_SLUG || 'siteimprove' }}
svn-username: ${{ secrets.WP_SVN_USERNAME }}
svn-password: ${{ secrets.WP_SVN_PASSWORD }}
svn-username: ${{ github.event.inputs.test-mode && secrets.TEST_SVN_USERNAME || secrets.WP_SVN_USERNAME }}
svn-password: ${{ github.event.inputs.test-mode && secrets.TEST_SVN_PASSWORD || secrets.WP_SVN_PASSWORD }}
svn-url: ${{ vars.WP_SVN_URL || 'https://plugins.svn.wordpress.org/siteimprove/' }}
assets-dir: ${{ vars.WP_ASSETS_DIR || 'wordpress-assets' }}
dry-run: ${{ github.event.inputs.dry-run || false }}
Expand Down
49 changes: 43 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10

jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -20,14 +21,50 @@ jobs:
with:
artifacts: 'siteimprove.zip'
token: ${{ secrets.GITHUB_TOKEN }}
- name: Deploy to WordPress Marketplace

deploy:
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
include:
# Dry run mode
- tag_pattern: '-dry-run'
mode: 'dry-run'
svn_username: ${{ secrets.WP_SVN_USERNAME }}
svn_password: ${{ secrets.WP_SVN_PASSWORD }}
svn_url: ${{ vars.WP_SVN_URL || 'https://plugins.svn.wordpress.org/siteimprove/' }}
dry_run: true
test_mode: false
# Test mode
- tag_pattern: '-test'
mode: 'test'
svn_username: ${{ secrets.TEST_SVN_USERNAME }}
svn_password: ${{ secrets.TEST_SVN_PASSWORD }}
svn_url: ${{ vars.TEST_SVN_URL }}
dry_run: false
test_mode: true
# Production mode
- tag_pattern: 'production'
mode: 'production'
svn_username: ${{ secrets.WP_SVN_USERNAME }}
svn_password: ${{ secrets.WP_SVN_PASSWORD }}
svn_url: ${{ vars.WP_SVN_URL || 'https://plugins.svn.wordpress.org/siteimprove/' }}
dry_run: false
test_mode: false
if: |
(contains(github.ref_name, matrix.tag_pattern) && matrix.tag_pattern != 'production') ||
(!contains(github.ref_name, '-test') && !contains(github.ref_name, '-dry-run') && matrix.tag_pattern == 'production')
steps:
- uses: actions/checkout@master
- name: Deploy to WordPress Marketplace (${{ matrix.mode }})
uses: ./.github/actions/deploy-to-wordpress
with:
version: ${{ github.ref_name }}
plugin-slug: ${{ vars.WP_PLUGIN_SLUG || 'siteimprove' }}
svn-username: ${{ secrets.WP_SVN_USERNAME }}
svn-password: ${{ secrets.WP_SVN_PASSWORD }}
svn-url: ${{ vars.WP_SVN_URL || 'https://plugins.svn.wordpress.org/siteimprove/' }}
svn-username: ${{ matrix.svn_username }}
svn-password: ${{ matrix.svn_password }}
svn-url: ${{ matrix.svn_url }}
assets-dir: ${{ vars.WP_ASSETS_DIR || 'wordpress-assets' }}
dry-run: false
test-mode: false
dry-run: ${{ matrix.dry_run }}
test-mode: ${{ matrix.test_mode }}
154 changes: 154 additions & 0 deletions RELEASE_GUIDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
# WordPress Plugin Release Guide

This guide explains how to release your WordPress plugin using different deployment modes.

## 🏷️ **Tag Patterns for Different Modes**

The release workflow automatically detects the deployment mode based on your git tag:

### **1. Dry Run Mode** (Safe Testing)
```bash
git tag v2.0.8-dry-run
git push origin v2.0.8-dry-run
```
**What happens:**
- ✅ Creates GitHub release with zip file
- ✅ Runs deployment in dry-run mode
- ✅ Shows what would be deployed
- ❌ No actual SVN operations
- ❌ No changes made to any repository

### **2. Test Mode** (Test Repository)
```bash
git tag v2.0.8-test
git push origin v2.0.8-test
```
**What happens:**
- ✅ Creates GitHub release with zip file
- ✅ Deploys to test SVN repository
- ✅ Uses test credentials
- ✅ Marks commits as "TEST:"
- ❌ No changes to production WordPress.org

### **3. Production Mode** (Live Deployment)
```bash
git tag v2.0.8
git push origin v2.0.8
```
**What happens:**
- ✅ Creates GitHub release with zip file
- ✅ Deploys to WordPress.org marketplace
- ✅ Uses production credentials
- ✅ Live deployment to users

## 🔧 **Prerequisites**

### **Required Secrets**
- `WP_SVN_USERNAME`: Your WordPress.org SVN username
- `WP_SVN_PASSWORD`: Your WordPress.org SVN password
- `TEST_SVN_USERNAME`: Your test SVN username (for test mode)
- `TEST_SVN_PASSWORD`: Your test SVN password (for test mode)

### **Required Variables**
- `WP_PLUGIN_SLUG`: Your WordPress.org plugin slug
- `WP_SVN_URL`: Your WordPress.org SVN repository URL
- `TEST_SVN_URL`: Your test SVN repository URL
- `WP_ASSETS_DIR`: Directory containing plugin assets

## 📋 **Release Process**

### **Step 1: Prepare Your Release**
1. Update version in `siteimprove/siteimprove.php`
2. Update changelog in `siteimprove/readme.txt`
3. Commit and push your changes
4. Test locally with `./scripts/test-deploy.sh`

### **Step 2: Choose Deployment Mode**

#### **For Testing (Recommended First)**
```bash
# Dry run to validate everything
git tag v2.0.8-dry-run
git push origin v2.0.8-dry-run

# Test with actual SVN operations
git tag v2.0.8-test
git push origin v2.0.8-test
```

#### **For Production**
```bash
# Live deployment to WordPress.org
git tag v2.0.8
git push origin v2.0.8
```

### **Step 3: Monitor the Workflow**
1. Go to **Actions** tab in your repository
2. Watch the workflow run
3. Check the logs for any issues
4. Verify the deployment was successful

## 🎯 **Recommended Workflow**

### **For New Versions:**
1. **Dry Run**: `v2.0.8-dry-run` - Validate files and process
2. **Test**: `v2.0.8-test` - Test with real SVN operations
3. **Production**: `v2.0.8` - Deploy to WordPress.org

### **For Minor Updates:**
1. **Test**: `v2.0.8-test` - Quick validation
2. **Production**: `v2.0.8` - Deploy to WordPress.org

## 🔍 **What to Check After Each Release**

### **Dry Run Mode:**
- ✅ Files are prepared correctly
- ✅ Version is updated
- ✅ No errors in the process
- ✅ Deployment preview looks correct

### **Test Mode:**
- ✅ Files are committed to test repository
- ✅ Tag is created in test repository
- ✅ Commit message starts with "TEST:"
- ✅ All files are present

### **Production Mode:**
- ✅ Files are committed to WordPress.org
- ✅ Tag is created on WordPress.org
- ✅ Plugin appears on WordPress.org
- ✅ Version is available for download

## 🚨 **Troubleshooting**

### **Common Issues:**

**"Workflow not triggered"**
- Ensure tag matches pattern: `v*`, `v*-test`, or `v*-dry-run`
- Check that tag was pushed to the repository

**"SVN authentication failed"**
- Verify credentials are set correctly
- Check that credentials have write access
- For test mode, ensure test repository exists

**"Files not found"**
- Ensure `siteimprove/` directory exists
- Check that main plugin file is present
- Verify file paths in the action

**"Version already exists"**
- Use a different version number
- Delete existing tag if needed
- Check WordPress.org for existing versions

## 📊 **Workflow Summary**

| Tag Pattern | Mode | SVN Operations | Credentials | Purpose |
|-------------|------|----------------|-------------|---------|
| `v2.0.8-dry-run` | Dry Run | ❌ None | Production | Validate files |
| `v2.0.8-test` | Test | ✅ Test repo | Test | Test deployment |
| `v2.0.8` | Production | ✅ WordPress.org | Production | Live release |

This approach ensures safe, controlled releases with multiple validation steps before going live.
Loading