diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..143840d --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,45 @@ +name: Publish + +on: + push: + tags: ["v*"] + +permissions: + contents: read + +jobs: + build: + name: Build distribution + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + + - uses: astral-sh/setup-uv@v10.4.0 + with: + version: "0.11.14" + + - name: Build sdist and wheel + run: uv build + + - name: Check package metadata + run: uvx twine check dist/* + + - uses: actions/upload-artifact@v7.0.2 + with: + name: dist + path: dist/ + + publish: + name: Publish to PyPI + needs: build + runs-on: ubuntu-latest + environment: pypi + permissions: + id-token: write + steps: + - uses: actions/download-artifact@v8.0.2 + with: + name: dist + path: dist/ + + - uses: pypa/gh-action-pypi-publish@v1.14.3 diff --git a/CHANGELOG.md b/CHANGELOG.md index bff9320..bd69c6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ All notable changes to this project are documented here. The format follows - Require `mcp>=1,<2`; the previous `<2` bound allowed an incompatible pre-1.0 MCP release to be selected. - CI now uses `actions/checkout@v7` and `actions/setup-python@v7`, and tests Python 3.11–3.14. - Added `uv.lock` and switched CI and development setup to locked installs (`uv sync --locked --extra dev` / `uv sync --extra dev`). +- Added a tag-triggered PyPI publishing workflow using Trusted Publishing, with the release checklist in `docs/releasing.md`. ## [0.4.0] — 2026-11-25 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f4b02e0..b7c34b3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -51,6 +51,10 @@ CI runs exactly these on Python 3.11 and 3.12 for every push to `main` and every set per event. 4. **Evidence is coordinate-level.** Every finding carries a location that a human can open. +## Releasing + +See [`docs/releasing.md`](docs/releasing.md) for the version bump, tag, and PyPI publishing steps. + ## Pull requests - Branch from `main`; `main` is the release line. diff --git a/docs/releasing.md b/docs/releasing.md new file mode 100644 index 0000000..7e91472 --- /dev/null +++ b/docs/releasing.md @@ -0,0 +1,47 @@ +# Releasing + +This project publishes from a version tag through `.github/workflows/publish.yml`. + +## One-time PyPI setup + +The workflow uses PyPI Trusted Publishing, so no API token is stored in GitHub. + +1. Create the `aiitg` project on PyPI (or use an existing project). +2. Add a trusted publisher with: + - owner: `sscodeai` + - repository: `aiitg` + - workflow: `publish.yml` + - environment: `pypi` +3. Create a GitHub environment named `pypi` and add protection rules if required by the repository. + +## Release checklist + +1. Bump the version in both places: + - `pyproject.toml` + - `src/aiitg/_version.py` +2. Move the `[Unreleased]` entries into a dated `[X.Y.Z]` section in `CHANGELOG.md`. +3. Run the gates: + ```bash + make test + make lint + make typecheck + uv build + uvx twine check dist/* + ``` +4. Open a release PR (`chore(release): X.Y.Z`) and merge it to `main`. +5. Create and push the annotated tag: + ```bash + git tag -a vX.Y.Z -m "aiitg X.Y.Z — " + git push github vX.Y.Z + ``` +6. The `Publish` workflow builds the sdist/wheel and publishes to PyPI via Trusted Publishing. +7. Create the GitHub Release for the tag: + ```bash + gh release create vX.Y.Z --repo sscodeai/aiitg --title "aiitg X.Y.Z" --generate-notes + ``` + +## Notes + +- `uv.lock` is checked in; run `uv lock` after changing dependencies. +- The publish workflow only runs for tags matching `v*`. +- PyPI publishes are immutable: a version number cannot be reused after upload.