# BaseCloud Shield - Deployment Guide

This guide explains the streamlined deployment system that eliminates the need to manually update version numbers in multiple files.

## 🚀 Quick Deployment Options

### Option 1: PowerShell Script (Recommended for Windows)
```powershell
# Patch version (1.0.0 → 1.0.1)
.\deploy.ps1 patch

# Minor version (1.0.0 → 1.1.0)
.\deploy.ps1 minor

# Major version (1.0.0 → 2.0.0)
.\deploy.ps1 major

# Specific version
.\deploy.ps1 1.2.3
```

### Option 2: Batch File (Simplest)
```cmd
# Double-click deploy.bat or run:
deploy.bat patch
deploy.bat minor
deploy.bat major
```

### Option 3: NPM Scripts
```bash
# Install npm first (if not already done)
npm install

# Deploy patch version
npm run deploy

# Deploy minor version
npm run deploy:minor

# Deploy major version
npm run deploy:major

# Check current version
npm run version:get
```

### Option 4: PHP Script (Cross-platform)
```bash
php deploy.php patch
php deploy.php minor
php deploy.php major
php deploy.php 1.2.3
```

## 📋 What Each Script Does

1. **Updates version number** in `basecloud-shield.php`
2. **Updates stable tag** in `readme.txt`
3. **Prompts for changelog** entry (manual step)
4. **Commits changes** to git
5. **Creates version tag** (e.g., v1.0.1)
6. **Pushes to repository** and triggers GitHub workflow
7. **Automatically deploys** to WordPress.org

## 🔧 Version Management System

### Single Source of Truth
- **Plugin version** is defined only in `basecloud-shield.php`
- **All scripts** read from this single source
- **No more manual updates** in multiple files

### Version Helper Functions
The `version-helper.php` file provides:
- `basecloud_shield_get_plugin_version()` - Get current version
- `basecloud_shield_update_readme_version()` - Update readme.txt
- `basecloud_shield_bump_version($type)` - Calculate next version

## 🎯 Deployment Workflow

```
1. Run deployment script
   ↓
2. Script updates version numbers automatically
   ↓
3. You add changelog entry (manual)
   ↓
4. Script commits & tags automatically
   ↓
5. GitHub workflow triggers
   ↓
6. Plugin deploys to WordPress.org
```

## 🛠️ Manual Version Update (if needed)

If you need to manually update versions:

1. **Update plugin file:**
   ```php
   // In basecloud-shield.php
   * Version: 1.0.1
   define('BCSHIELD_VERSION', '1.0.1');
   ```

2. **Update readme.txt:**
   ```
   Stable tag: 1.0.1
   ```

3. **Add changelog entry:**
   ```
   == Changelog ==
   
   = 1.0.1 =
   * Your changes here
   ```

## 📦 SVN Deployment (Manual Alternative)

If you prefer to deploy manually to WordPress.org SVN:

```bash
# Navigate to svn-repo
cd svn-repo

# Update from SVN
svn update

# Copy files to trunk
# (Excluding development files)
xcopy ..\basecloud-shield.php trunk\ /Y
xcopy ..\readme.txt trunk\ /Y

# Copy assets
xcopy ..\assets\*.png assets\ /Y

# Add new files
svn add --force *

# Commit to trunk
svn commit -m "Updated to version 1.0.1"

# Create tag
svn copy ^/trunk ^/tags/1.0.1 -m "Tagging version 1.0.1"
```

## 🔐 GitHub Actions Auto-Deployment

The repository includes a GitHub Actions workflow that automatically deploys to WordPress.org when you push a version tag.

**How it works:**
1. Push version tag to GitHub: `git push origin v1.0.1`
2. GitHub Actions detects the tag
3. Workflow runs automated tests
4. Plugin is automatically deployed to WordPress.org SVN

**Workflow file:** `.github/workflows/deploy.yml`

## 📝 Best Practices

1. **Always test locally** before deploying
2. **Update changelog** with meaningful descriptions
3. **Use semantic versioning**: 
   - Patch (1.0.x) - Bug fixes
   - Minor (1.x.0) - New features, backward compatible
   - Major (x.0.0) - Breaking changes
4. **Tag important releases** in GitHub
5. **Keep assets updated** (icons, banners, screenshots)

## 🚨 Troubleshooting

### "Git commit failed"
- Make sure you have uncommitted changes
- Check git status: `git status`

### "Could not find version in plugin file"
- Ensure the Version header is properly formatted
- Check for the BCSHIELD_VERSION constant

### "Failed to push to repository"
- Verify you have push access to the repository
- Check your git credentials
- Make sure you're on the main branch

### "SVN authentication failed"
- Update your SVN credentials
- Check your WordPress.org username/password

## 📞 Support

For deployment issues:
- Check GitHub Actions logs: https://github.com/BaseCloudGlobal/BaseCloudShield/actions
- Review deployment workflow status
- Contact BaseCloud Team

## 🎓 First-Time Setup

### GitHub Repository Setup
```bash
# Initialize git (if not already done)
git init

# Add remote
git remote add origin https://github.com/BaseCloudGlobal/BaseCloudShield.git

# Initial commit
git add .
git commit -m "Initial commit"
git push -u origin main
```

### WordPress.org SVN Setup
```bash
# Checkout SVN repository (one-time only)
svn checkout https://plugins.svn.wordpress.org/basecloud-shield svn-repo

# This creates the svn-repo folder with trunk, tags, and assets directories
```

## 📊 Version History

| Version | Date | Changes |
|---------|------|---------|
| 1.0.0   | 2026-01-19 | Initial release |

---

**Made with ❤️ by BaseCloud Team**
