|
1 |
| -# pychangesets |
2 |
| -A versioning tool for python projects inspired by changesets. |
| 1 | +# pychangeset |
| 2 | + |
| 3 | +A tool for automating version bumps, changelog generation and release PRs in Python projects, inspired by [Changesets](https://github.com/changesets/changesets). |
| 4 | + |
| 5 | +## Installation |
| 6 | + |
| 7 | +```bash |
| 8 | +# Use with uvx (recommended) |
| 9 | +uvx changeset |
| 10 | + |
| 11 | +# Or install from PyPI |
| 12 | +pip install pychangeset |
| 13 | +``` |
| 14 | + |
| 15 | +## Quick Start |
| 16 | + |
| 17 | +### 0. Initialize |
| 18 | + |
| 19 | +```bash |
| 20 | +uvx changeset |
| 21 | +``` |
| 22 | + |
| 23 | +This will: |
| 24 | +- Run `changeset init`, creating a .changeset/ directory in your project |
| 25 | +- Prompt the user to `add` a changeset, which will: |
| 26 | + - Detect which packages have changes |
| 27 | + - Ask what type of change for each (major/minor/patch) |
| 28 | + - Prompt for a description |
| 29 | + - Create a changeset file in `.changeset/` |
| 30 | + |
| 31 | +### 1. Track `.changset/` |
| 32 | + |
| 33 | +```bash |
| 34 | +git add .changeset/ |
| 35 | +git commit -m "Add changeset" |
| 36 | +git push |
| 37 | +``` |
| 38 | + |
| 39 | +### 2. Automated Release Process |
| 40 | + |
| 41 | +To get the most value out of `changeset`, use the GitHub workflows in (`.github/workflows`) |
| 42 | + |
| 43 | +When you merge to your main branch, GitHub Actions will: |
| 44 | +1. Create or update a Release PR with: |
| 45 | + - Updated CHANGELOG.md files |
| 46 | + - Bumped version numbers |
| 47 | + - Consolidated PR description |
| 48 | +2. When the Release PR is merged: |
| 49 | + - Publish packages to PyPI |
| 50 | + - Create git tags |
| 51 | + - Create GitHub releases |
| 52 | + |
| 53 | +## GitHub Actions Setup |
| 54 | + |
| 55 | +Add these workflows to your repository: |
| 56 | + |
| 57 | +### `.github/workflows/changesets.yml` |
| 58 | + |
| 59 | +When you merge to your main branch, the `changesets` workflow will create or update a Release PR with: |
| 60 | + - Updated CHANGELOG.md files |
| 61 | + - Bumped version numbers |
| 62 | + - Consolidated PR description |
| 63 | + |
| 64 | +### `.github/workflows/release.yml` |
| 65 | + |
| 66 | +When the Release PR is merged, the `release` workflow: |
| 67 | +- Publishes packages to PyPI |
| 68 | +- Creates git tags |
| 69 | +- Creates GitHub releases |
| 70 | + |
| 71 | +## Commands |
| 72 | + |
| 73 | +### `changeset init` |
| 74 | +Initialize changesets in your project. |
| 75 | + |
| 76 | +### `changeset add` / `changeset` |
| 77 | +Create a new changeset interactively. |
| 78 | + |
| 79 | +Options: |
| 80 | +- `--all`: Include all packages without prompting |
| 81 | + |
| 82 | +### `changeset version` |
| 83 | +Process changesets and bump versions. |
| 84 | + |
| 85 | +Options: |
| 86 | +- `--dry-run`: Preview changes without applying them |
| 87 | +- `--skip-changelog`: Skip changelog generation |
| 88 | + |
| 89 | +### `changeset changelog` |
| 90 | +Generate changelogs from changesets. |
| 91 | + |
| 92 | +Options: |
| 93 | +- `--dry-run`: Preview changelog without writing files |
| 94 | +- `--output-pr-description <file>`: Write PR description to file |
| 95 | + |
| 96 | +### `changeset check-changeset` |
| 97 | +Check if changesets exist for the current branch (useful for CI). |
| 98 | + |
| 99 | +Options: |
| 100 | +- `--skip-ci`: Skip check in CI environment |
| 101 | + |
| 102 | +## Changelog Format |
| 103 | + |
| 104 | +Changelogs are generated with PR and commit metadata: |
| 105 | + |
| 106 | +```markdown |
| 107 | +# package-name |
| 108 | + |
| 109 | +## 1.2.0 |
| 110 | + |
| 111 | +### Minor Changes |
| 112 | + |
| 113 | +- [#123](link-to-pr) [`abc123`](link-to-commit) Thanks @username! - Description of change |
| 114 | + |
| 115 | +### Patch Changes |
| 116 | + |
| 117 | +- [#124](link-to-pr) [`def456`](link-to-commit) Thanks @username! - Bug fix description |
| 118 | +``` |
| 119 | + |
| 120 | +## Development |
| 121 | + |
| 122 | +```bash |
| 123 | +# Clone the repository |
| 124 | +git clone https://github.com/browserbase/pychangeset.git |
| 125 | +cd pychangeset |
| 126 | + |
| 127 | +# Install with uv |
| 128 | +uv sync |
| 129 | + |
| 130 | +# Run tests |
| 131 | +uv run pytest |
| 132 | + |
| 133 | +# Run the tool locally |
| 134 | +uv run changeset |
| 135 | +``` |
| 136 | + |
| 137 | +## License |
| 138 | + |
| 139 | +MIT |
0 commit comments