|
| 1 | +# Publishing stagehand-python to PyPI |
| 2 | + |
| 3 | +This repository is configured with a GitHub Actions workflow to automate the process of publishing new versions to PyPI. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +Before using the publishing workflow, ensure you have: |
| 8 | + |
| 9 | +1. Set up the following secrets in your GitHub repository settings: |
| 10 | + - `PYPI_USERNAME`: Your PyPI username |
| 11 | + - `PYPI_API_TOKEN`: Your PyPI API token (not your password) |
| 12 | + |
| 13 | +## How to Publish a New Version |
| 14 | + |
| 15 | +### Manual Trigger |
| 16 | + |
| 17 | +1. Go to the "Actions" tab in your GitHub repository |
| 18 | +2. Select the "Publish to PyPI" workflow from the list |
| 19 | +3. Click "Run workflow" on the right side |
| 20 | +4. Configure the workflow: |
| 21 | + - Choose the release type: |
| 22 | + - `patch` (e.g., 0.3.0 → 0.3.1) for bug fixes |
| 23 | + - `minor` (e.g., 0.3.0 → 0.4.0) for backward-compatible features |
| 24 | + - `major` (e.g., 0.3.0 → 1.0.0) for breaking changes |
| 25 | + - Toggle "Create GitHub Release" if you want to create a GitHub release |
| 26 | +5. Click "Run workflow" to start the process |
| 27 | + |
| 28 | +### What Happens During Publishing |
| 29 | + |
| 30 | +The workflow will: |
| 31 | + |
| 32 | +1. Checkout the repository |
| 33 | +2. Set up Python environment |
| 34 | +3. Install dependencies |
| 35 | +4. **Run Ruff linting checks**: |
| 36 | + - Checks for code style and quality issues |
| 37 | + - Verifies formatting according to project standards |
| 38 | + - Fails the workflow if issues are found |
| 39 | +5. Run tests to ensure everything works |
| 40 | +6. Update the version number using bumpversion |
| 41 | +7. Build the package |
| 42 | +8. Upload to PyPI |
| 43 | +9. Push the version bump commit and tag |
| 44 | +10. Create a GitHub release (if selected) |
| 45 | + |
| 46 | +## Code Quality Standards |
| 47 | + |
| 48 | +This project uses Ruff for linting and formatting. The workflow enforces these standards before publishing: |
| 49 | + |
| 50 | +- Style checks following configured rules in `pyproject.toml` |
| 51 | +- Format verification without making changes |
| 52 | +- All linting issues must be fixed before a successful publish |
| 53 | + |
| 54 | +To run the same checks locally: |
| 55 | +```bash |
| 56 | +# Install Ruff |
| 57 | +pip install ruff |
| 58 | + |
| 59 | +# Run linting |
| 60 | +ruff check . |
| 61 | + |
| 62 | +# Check formatting |
| 63 | +ruff format --check . |
| 64 | + |
| 65 | +# Auto-fix issues where possible |
| 66 | +ruff check --fix . |
| 67 | +ruff format . |
| 68 | + |
| 69 | +# Use Black to format the code |
| 70 | +black . |
| 71 | +``` |
| 72 | + |
| 73 | +## Troubleshooting |
| 74 | + |
| 75 | +If the workflow fails, check the following: |
| 76 | + |
| 77 | +1. **Linting errors**: Fix any issues reported by Ruff |
| 78 | +2. Ensure all secrets are properly set |
| 79 | +3. Verify that tests pass locally |
| 80 | +4. Check if you have proper permissions on the repository |
| 81 | +5. Make sure you have a PyPI account with publishing permissions |
0 commit comments