# BaseCloud Security Manager - 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.5 → 1.0.6)
.\deploy.ps1 patch

# Minor version (1.0.5 → 1.1.0)
.\deploy.ps1 minor

# Major version (1.0.5 → 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-security-manager-bc.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.6)
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-security-manager-bc.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_get_plugin_version()` - Get current version
- `basecloud_update_readme_version()` - Update readme.txt
- `basecloud_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
   * Version: 1.0.6
   ```

2. **Update readme.txt:**
   ```
   Stable tag: 1.0.6
   ```

3. **Add changelog entry**

4. **Run git commands:**
   ```bash
   git add .
   git commit -m "Version 1.0.6: Update description"
   git tag v1.0.6
   git push origin local
   git push origin v1.0.6
   ```

## 🎨 WordPress Plugin Assets

The deployment system now includes automatic validation and deployment of WordPress plugin assets:

### Asset Types Supported
- **Plugin Icons**: 128x128px and 256x256px PNG files
- **Plugin Banners**: 772x250px and 1544x500px PNG/JPG files  
- **Screenshots**: Any size PNG/JPG files (recommended 1200x900px)

### Adding Assets
1. Create `/assets/` directory (auto-created if missing)
2. Add your asset files with exact naming:
   - `icon-128x128.png`
   - `icon-256x256.png`
   - `banner-772x250.png`
   - `banner-1544x500.png`
   - `screenshot-1.png`, `screenshot-2.png`, etc.
3. Run deployment as usual

### Asset Validation
During deployment, the system automatically:
- ✅ Validates image dimensions and formats
- ✅ Reports missing or invalid assets
- ✅ Provides specific error messages and guidance
- ✅ Allows deployment to continue even with missing assets

Example validation output:
```
🔍 Validating WordPress plugin assets...
   ✅ icon-128x128.png: Valid (128 x 128)
   ⚠️  banner-772x250.png: Not found (optional)
   📊 Assets summary: 1 files found
```

See [ASSETS.md](ASSETS.md) for complete asset guidelines and troubleshooting.

## 🚨 Important Notes

- **Always test** your plugin before deploying
- **Add meaningful changelog entries** for each version
- **The GitHub workflow** automatically deploys to WordPress.org
- **Version numbers** follow semantic versioning (major.minor.patch)
- **Tags must start with 'v'** to trigger the workflow

## 🔍 Troubleshooting

### Script doesn't run
- Ensure PowerShell execution policy allows scripts
- Run: `Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser`

### Git errors
- Ensure you're in the correct directory
- Check that you have git configured and authenticated

### Workflow doesn't trigger
- Verify the tag was pushed: `git tag -l`
- Check GitHub Actions tab in repository

## 📞 Support

If you encounter issues with the deployment system:
1. Check the error messages carefully
2. Ensure all files are committed before deployment
3. Verify your git configuration is correct
4. Contact support at support@basecloudglobal.com
