diff --git a/.github/workflows/python-release.yml b/.github/workflows/python-release.yml new file mode 100644 index 0000000..43400b5 --- /dev/null +++ b/.github/workflows/python-release.yml @@ -0,0 +1,41 @@ +name: Python Release + +on: + release: + types: [published] + +jobs: + test: + uses: ./.github/workflows/python-test.yml + + publish: + needs: test + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/project/gtfs-diff-engine/ + permissions: + id-token: write # Required for PyPI Trusted Publisher (OIDC) + contents: read + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Install build backend + run: | + python -m pip install --upgrade pip + pip install build + + - name: Build distributions + run: | + python -m build + + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + verbose: true diff --git a/.github/workflows/python-test.yml b/.github/workflows/python-test.yml new file mode 100644 index 0000000..f715615 --- /dev/null +++ b/.github/workflows/python-test.yml @@ -0,0 +1,29 @@ +name: Python Tests + +on: + workflow_call: + workflow_dispatch: + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + # Oldest and latest supported versions — sufficient to catch compatibility issues + python-version: ["3.10", "3.12", "3.14"] + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install package + run: | + python -m pip install --upgrade pip + pip install -e ".[dev]" + + - name: Run tests + run: python -m pytest tests/ -v diff --git a/README.md b/README.md index 4f0684d..6482b44 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ pip install gtfs-diff-engine For a development (editable) install with test dependencies: ```bash -git clone https://github.com/your-org/gtfs-diff-engine +git clone https://github.com/MobilityData/gtfs-diff-engine cd gtfs-diff-engine pip install -e ".[dev]" ``` @@ -240,6 +240,30 @@ pip install -e ".[dev]" 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`. + +3. **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. + +5. **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`. + ## License See [LICENSE](LICENSE).