|
| 1 | +# Scripts |
| 2 | + |
| 3 | +This directory contains utility scripts for Linearator development and release management. |
| 4 | + |
| 5 | +## Release Preparation Script |
| 6 | + |
| 7 | +### `prepare_release.py` |
| 8 | + |
| 9 | +Automates the process of preparing a new release by updating version numbers across the codebase. |
| 10 | + |
| 11 | +#### Usage |
| 12 | + |
| 13 | +```bash |
| 14 | +# Basic usage |
| 15 | +python scripts/prepare_release.py 1.2.3 |
| 16 | + |
| 17 | +# Via Makefile (recommended) |
| 18 | +make prepare-release VERSION=1.2.3 |
| 19 | + |
| 20 | +# Dry run to see what would change |
| 21 | +python scripts/prepare_release.py 1.2.3 --dry-run |
| 22 | + |
| 23 | +# Skip changelog entry |
| 24 | +python scripts/prepare_release.py 1.2.3 --no-changelog |
| 25 | +``` |
| 26 | + |
| 27 | +#### What it does |
| 28 | + |
| 29 | +1. **Validates version format** - Ensures semantic versioning (X.Y.Z) |
| 30 | +2. **Updates version in multiple files:** |
| 31 | + - `pyproject.toml` - Package version |
| 32 | + - `src/linear_cli/__init__.py` - Python module version |
| 33 | + - `tests/unit/test_cli_basic.py` - Test version assertion |
| 34 | +3. **Creates changelog entry** - Adds new release section to `CHANGELOG.md` |
| 35 | +4. **Provides next steps** - Shows what to do after running the script |
| 36 | + |
| 37 | +#### Files Updated |
| 38 | + |
| 39 | +| File | What's Updated | |
| 40 | +|------|----------------| |
| 41 | +| `pyproject.toml` | `version = "X.Y.Z"` | |
| 42 | +| `src/linear_cli/__init__.py` | `__version__ = "X.Y.Z"` | |
| 43 | +| `tests/unit/test_cli_basic.py` | Version assertion in tests | |
| 44 | +| `CHANGELOG.md` | New release section with template | |
| 45 | + |
| 46 | +#### Example Output |
| 47 | + |
| 48 | +```bash |
| 49 | +$ make prepare-release VERSION=1.2.3 |
| 50 | + |
| 51 | +🚀 Preparing release 1.2.3 |
| 52 | +📦 Current version: 1.2.2 |
| 53 | +✅ Updated version in pyproject.toml |
| 54 | +✅ Updated __version__ in src/linear_cli/__init__.py |
| 55 | +✅ Updated version assertion in tests/unit/test_cli_basic.py |
| 56 | +✅ Added 1.2.3 section to CHANGELOG.md |
| 57 | +📝 Please edit CHANGELOG.md to add release notes |
| 58 | + |
| 59 | +🎉 Successfully prepared release 1.2.3! |
| 60 | + |
| 61 | +Next steps: |
| 62 | +1. Edit CHANGELOG.md to add release notes |
| 63 | +2. Run tests: make test |
| 64 | +3. Commit changes: git add . && git commit -m 'chore: prepare release v1.2.3' |
| 65 | +4. Create release: git tag v1.2.3 && git push origin v1.2.3 |
| 66 | +5. Publish GitHub release to trigger PyPI upload |
| 67 | +``` |
| 68 | + |
| 69 | +#### Complete Release Workflow |
| 70 | + |
| 71 | +1. **Prepare release:** |
| 72 | + ```bash |
| 73 | + make prepare-release VERSION=1.2.3 |
| 74 | + ``` |
| 75 | + |
| 76 | +2. **Edit changelog** - Fill in release notes in `CHANGELOG.md` |
| 77 | + |
| 78 | +3. **Run tests:** |
| 79 | + ```bash |
| 80 | + make test |
| 81 | + ``` |
| 82 | + |
| 83 | +4. **Commit and tag:** |
| 84 | + ```bash |
| 85 | + git add . |
| 86 | + git commit -m "chore: prepare release v1.2.3" |
| 87 | + git tag v1.2.3 |
| 88 | + git push origin main |
| 89 | + git push origin v1.2.3 |
| 90 | + ``` |
| 91 | + |
| 92 | +5. **Create GitHub release** - This triggers automated PyPI publishing |
| 93 | + |
| 94 | +#### Error Handling |
| 95 | + |
| 96 | +The script includes comprehensive error handling: |
| 97 | + |
| 98 | +- **Invalid version format** - Must be semantic versioning (X.Y.Z) |
| 99 | +- **Missing files** - Warns if expected files aren't found |
| 100 | +- **Pattern matching failures** - Reports if version patterns can't be found |
| 101 | +- **File write errors** - Handles permission and disk space issues |
| 102 | + |
| 103 | +#### Options |
| 104 | + |
| 105 | +- `--dry-run` - Preview changes without making them |
| 106 | +- `--no-changelog` - Skip adding changelog entry |
| 107 | +- `--help` - Show usage information |
| 108 | + |
| 109 | +#### Integration |
| 110 | + |
| 111 | +The script is integrated with the project's Makefile for easy usage: |
| 112 | + |
| 113 | +```bash |
| 114 | +# Prepare release (will prompt for VERSION if not provided) |
| 115 | +make prepare-release VERSION=1.2.3 |
| 116 | + |
| 117 | +# Check all release prerequisites |
| 118 | +make release-check |
| 119 | +``` |
0 commit comments