|
| 1 | +# GitHub Actions & Automation |
| 2 | + |
| 3 | +This directory contains GitHub Actions workflows and automation scripts for CI/CD. |
| 4 | + |
| 5 | +## 📁 Contents |
| 6 | + |
| 7 | +- **`bump_version.py`** - Automated version bumping script |
| 8 | +- **`VERSION_BUMP_USAGE.txt`** - Quick reference for version commands |
| 9 | +- **`hooks/`** - Git hooks for version consistency checks |
| 10 | +- **`workflows/`** - GitHub Actions workflow definitions |
| 11 | + |
| 12 | +## 🔄 Version Management |
| 13 | + |
| 14 | +### Quick Start |
| 15 | + |
| 16 | +```bash |
| 17 | +# Bump version (from project root) |
| 18 | +python .github/bump_version.py patch # 4.0.0 → 4.0.1 |
| 19 | +python .github/bump_version.py minor # 4.0.0 → 4.1.0 |
| 20 | +python .github/bump_version.py major # 4.0.0 → 5.0.0 |
| 21 | + |
| 22 | +# Or from .github directory |
| 23 | +cd .github |
| 24 | +python bump_version.py patch |
| 25 | +``` |
| 26 | + |
| 27 | +See `VERSION_BUMP_USAGE.txt` for complete documentation. |
| 28 | + |
| 29 | +## Workflows |
| 30 | + |
| 31 | +### 1. `test-build.yml` - Automated Testing |
| 32 | + |
| 33 | +**Triggers:** |
| 34 | +- Push to main/master/develop branches |
| 35 | +- Pull requests |
| 36 | +- Manual trigger |
| 37 | + |
| 38 | +**What it does:** |
| 39 | +- Tests building on Ubuntu, Windows, and macOS |
| 40 | +- Tests with Python 3.7, 3.8, 3.9, 3.10, 3.11 |
| 41 | +- Verifies package integrity |
| 42 | +- Tests installation |
| 43 | +- Tests command availability |
| 44 | + |
| 45 | +### 2. `manual-version-bump.yml` - Manual Version Bumping |
| 46 | + |
| 47 | +**Triggers:** |
| 48 | +- Manual: Via Actions tab |
| 49 | + |
| 50 | +**What it does:** |
| 51 | +- Bumps version (patch/minor/major) |
| 52 | +- Updates all version files |
| 53 | +- Commits and pushes changes |
| 54 | +- Creates Git tag |
| 55 | +- Generates changelog |
| 56 | +- Creates GitHub Release |
| 57 | + |
| 58 | +### 3. `auto-version-bump.yml` - Automatic Version Bumping |
| 59 | + |
| 60 | +**Triggers:** |
| 61 | +- Push to main/master branch |
| 62 | + |
| 63 | +**What it does:** |
| 64 | +- Detects bump type from commit messages |
| 65 | +- Auto-bumps version accordingly |
| 66 | +- Creates release automatically |
| 67 | +- Skips with `[skip version]` in commit |
| 68 | + |
| 69 | +### 4. `publish-to-pypi.yml` - Automated Deployment |
| 70 | + |
| 71 | +**Triggers:** |
| 72 | +- Automatic: When a GitHub release is published |
| 73 | +- Manual: Via Actions tab (select TestPyPI or PyPI) |
| 74 | + |
| 75 | +**What it does:** |
| 76 | +- Verifies version consistency |
| 77 | +- Builds the package |
| 78 | +- Validates with twine |
| 79 | +- Publishes to TestPyPI or PyPI |
| 80 | +- Uploads build artifacts |
| 81 | + |
| 82 | +## Setup Required |
| 83 | + |
| 84 | +### GitHub Secrets |
| 85 | + |
| 86 | +Add these secrets to the repository: |
| 87 | + |
| 88 | +1. **PYPI_API_TOKEN** |
| 89 | + - Get from: https://pypi.org/manage/account/token/ |
| 90 | + - Add at: Repository Settings → Secrets → Actions |
| 91 | + |
| 92 | +2. **TEST_PYPI_API_TOKEN** |
| 93 | + - Get from: https://test.pypi.org/manage/account/token/ |
| 94 | + - Add at: Repository Settings → Secrets → Actions |
| 95 | + |
| 96 | +## Usage |
| 97 | + |
| 98 | +### Version Bumping & Release (Recommended) |
| 99 | + |
| 100 | +**Option 1: Manual via GitHub Actions** |
| 101 | +1. Go to Actions tab |
| 102 | +2. Select "Manual Version Bump" |
| 103 | +3. Click "Run workflow" |
| 104 | +4. Choose bump type (patch/minor/major) |
| 105 | +5. Workflow automatically: |
| 106 | + - Bumps version |
| 107 | + - Creates tag |
| 108 | + - Creates release |
| 109 | + - Triggers PyPI deployment |
| 110 | + |
| 111 | +**Option 2: Local Script** |
| 112 | +```bash |
| 113 | +# Bump version locally |
| 114 | +python .github/bump_version.py patch |
| 115 | +git push origin main --tags |
| 116 | +``` |
| 117 | + |
| 118 | +**Option 3: Automatic via Commit Messages** |
| 119 | +```bash |
| 120 | +# Commit with conventional format |
| 121 | +git commit -m "feat: new feature" # → minor bump |
| 122 | +git commit -m "fix: bug fix" # → patch bump |
| 123 | +git commit -m "feat!: breaking change" # → major bump |
| 124 | +git push origin main |
| 125 | +``` |
| 126 | + |
| 127 | +### Manual PyPI Deployment |
| 128 | + |
| 129 | +1. Go to Actions tab |
| 130 | +2. Select "Publish to PyPI" |
| 131 | +3. Click "Run workflow" |
| 132 | +4. Choose environment (testpypi or pypi) |
| 133 | +5. Click "Run workflow" |
| 134 | + |
| 135 | +## Monitoring |
| 136 | + |
| 137 | +View workflow status: |
| 138 | +- Actions tab: https://github.com/Pymmdrza/spyhunt/actions |
| 139 | +- Email notifications on failures |
| 140 | +- Download artifacts from workflow runs |
| 141 | + |
| 142 | +## Documentation |
| 143 | + |
| 144 | +See [GITHUB_ACTIONS_DEPLOYMENT.md](../GITHUB_ACTIONS_DEPLOYMENT.md) for complete guide. |
| 145 | + |
0 commit comments