Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/python-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
Expand Down
16 changes: 5 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -376,27 +376,21 @@ pytest tests/ -v

## Releasing a New Version

1. **Bump the version** in `pyproject.toml`:
```toml
[project]
version = "x.y.z"
```

2. **Commit and push** the version bump to `main`.
The version is derived automatically from git tags via `hatch-vcs` — no manual version bumps needed.

3. **Create a GitHub Release** via the GitHub UI (or `gh release create`):
1. **Create a GitHub Release** via the GitHub UI (or `gh release create`):
- Set the tag to `vx.y.z` (e.g. `v0.2.0`)
- Write a release title and notes summarising changes
- Click **Publish release**

4. **The publish workflow fires automatically.** The [`Publish to PyPI`](.github/workflows/publish.yml) GitHub Actions workflow triggers on release publication, builds the package, and pushes it to PyPI via [Trusted Publisher (OIDC)](https://docs.pypi.org/trusted-publishers/) — no API token required.
2. **The publish workflow fires automatically.** The [`python-release.yml`](.github/workflows/python-release.yml) GitHub Actions workflow triggers on release publication, builds the package (reading the version from the git tag), and pushes it to PyPI via [Trusted Publisher (OIDC)](https://docs.pypi.org/trusted-publishers/) — no API token required.

5. **Verify** the new version appears on [https://pypi.org/project/gtfs-diff-engine](https://pypi.org/project/gtfs-diff-engine) and is installable:
3. **Verify** the new version appears on [https://pypi.org/project/gtfs-diff-engine](https://pypi.org/project/gtfs-diff-engine) and is installable:
```bash
pip install gtfs-diff-engine==x.y.z
```

> **One-time PyPI setup:** A maintainer must configure the repository as a Trusted Publisher on PyPI before the first automated release. Go to the [gtfs-diff-engine PyPI project](https://pypi.org/manage/project/gtfs-diff-engine/settings/publishing/), add a publisher for `MobilityData/gtfs-diff-engine`, workflow `publish.yml`, environment `pypi`.
> **One-time PyPI setup:** A maintainer must configure the repository as a Trusted Publisher on PyPI before the first automated release. Go to the [gtfs-diff-engine PyPI project](https://pypi.org/manage/project/gtfs-diff-engine/settings/publishing/), add a publisher for `MobilityData/gtfs-diff-engine`, workflow `python-release.yml`, environment `pypi`.

## License

Expand Down
14 changes: 10 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[build-system]
requires = ["hatchling"]
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"

[project]
name = "gtfs-diff-engine"
version = "0.1.0"
dynamic = ["version"]
description = "A diff engine for GTFS (General Transit Feed Specification) feeds"
requires-python = ">=3.10"
dependencies = [
Expand All @@ -26,6 +26,12 @@ dev = [
[project.scripts]
gtfs-diff = "gtfs_diff.cli:main"

[tool.hatch.version]
source = "vcs"

[tool.hatch.build.hooks.vcs]
version-file = "src/gtfs_diff/_version.py"

[tool.hatch.build.targets.wheel]
packages = ["src/gtfs_diff"]

Expand All @@ -35,7 +41,7 @@ testpaths = ["tests"]
[tool.ruff]
target-version = "py310"
src = ["src", "tests"]
exclude = ["src/gtfs_diff/models.py"]
exclude = ["src/gtfs_diff/models.py", "src/gtfs_diff/_version.py"]

[tool.ruff.lint]
select = [
Expand All @@ -48,4 +54,4 @@ select = [
]

[tool.ruff.format]
exclude = ["src/gtfs_diff/models.py"]
exclude = ["src/gtfs_diff/models.py", "src/gtfs_diff/_version.py"]
7 changes: 6 additions & 1 deletion src/gtfs_diff/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
"""GTFS Diff Engine - compare two GTFS feeds and surface structured differences."""

__version__ = "0.1.0"
from importlib.metadata import PackageNotFoundError, version

try:
__version__ = version("gtfs-diff-engine")
except PackageNotFoundError:
__version__ = "unknown"
2 changes: 1 addition & 1 deletion src/gtfs_diff/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


@click.command()
@click.version_option(version="0.1.0", prog_name="gtfs-diff-engine")
@click.version_option(package_name="gtfs-diff-engine", prog_name="gtfs-diff-engine")
@click.argument("base_feed", type=str)
@click.argument("new_feed", type=str)
@click.option(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_version(self):
runner = CliRunner()
result = runner.invoke(main, ["--version"])
assert result.exit_code == 0
assert "0.1.0" in result.output
assert "gtfs-diff-engine" in result.output


class TestDiffToStdout:
Expand Down