Release Notes Scripts
This directory contains Python scripts for managing release notes, version bumping, and changelog updates.
Development Setup
Prerequisites
- Python 3.10 or higher
- uv - Fast Python package installer
brew install uv - act - Run GitHub Actions locally
brew install act
Environment Variables
For local testing, you'll need:
OPENROUTER_API_KEY- Your OpenRouter API key for release notes generation
Setting Up Development Environment
-
Create and activate a virtual environment:
cd .github/scripts uv venv source .venv/bin/activate # On Unix/macOS # or .venv\Scripts\activate # On Windows -
Install dependencies:
uv pip install -r requirements.txt
Running Tests
With the virtual environment activated:
# Run all tests (including integration tests)
python -m pytest test_*.py -v --api-key=your_openrouter_api_key
# Run tests with coverage report
python -m pytest test_*.py -v --cov=. --cov-report=term-missing --api-key=your_openrouter_api_key
# Run specific test file
python -m pytest test_version_manager.py -v
# Run specific test
python -m pytest test_version_manager.py::TestVersionManager::test_bump_version -v
# Run unit tests only (excluding integration tests)
python -m pytest test_*.py -v --ignore=test_integration.py
# Run integration tests only
python -m pytest test_integration.py -v --api-key=your_openrouter_api_key
Integration Testing
The test suite includes integration tests that verify:
- Complete release flow with OpenRouter API calls
- Error handling (rate limits, invalid keys)
- Changelog updates and version management
Integration tests require a valid OpenRouter API key passed via the --api-key parameter. This ensures:
- Real API interactions are tested
- No reliance on environment variables
- Clear separation between unit and integration tests
- Explicit API key management
Scripts Overview
version_manager.py
Handles version bumping based on changesets. Determines the appropriate version bump (major, minor, patch) based on accumulated changes.
python version_manager.py --release-type release
python version_manager.py --release-type pre-release
generate_release_notes.py
Generates release notes using OpenRouter's Claude model. Analyzes changesets and git history to create comprehensive release notes.
python generate_release_notes.py \
--release-type release \
--version v3.3.0 \
--changesets '[{"type":"major","content":"Added new feature"}]' \
--api-key your_openrouter_api_key
overwrite_changeset_changelog.py
Updates CHANGELOG.md with new release notes, maintaining proper formatting and structure.
python overwrite_changeset_changelog.py \
--version v3.3.0 \
--content "Release notes content" \
--changelog-path CHANGELOG.md
End-to-End Testing
test-release.sh
Runs the complete release workflow locally using GitHub CLI, exactly as it would run in production:
# Run a test pre-release
./test-release.sh
This script triggers the publish workflow with pre-release mode, allowing you to verify:
- Version bumping from changesets
- Release notes generation
- Changelog updates
- Complete workflow integration
Testing
The test suite includes:
- Unit tests for all core functionality
- Integration tests with real API calls
- Mock git commands and file operations
- Edge case handling
- Pre-release to release transitions
- Error scenarios
Test Files
test_version_manager.py: Tests version bumping logictest_generate_release_notes.py: Tests release notes generationtest_overwrite_changelog.py: Tests changelog updatingtest_integration.py: End-to-end integration tests
Command Line Arguments
For Tests
--api-key: Required for integration tests. Provides the OpenRouter API key.
For Scripts
--release-type: Type of release (release or pre-release)--version: Version number for the release--changesets: JSON string of changes--content: Release notes content--changelog-path: Path to changelog file--github-output: Optional, path for GitHub Actions output--api-key: Required for generate_release_notes.py, OpenRouter API key
Adding New Tests
- Create test file following the naming convention
test_*.py - Use pytest fixtures for common setup
- Mock external dependencies (git commands, file operations)
- Include both success and error cases
- Add to existing test suite
Example:
def test_new_feature(self):
# Unit test example
result = my_function()
assert result == expected_value
def test_api_integration(self, api_key):
# Integration test example
result = my_api_function(api_key=api_key)
assert result is not None