# Releasing cli-agent-orchestrator This project publishes to [PyPI](https://pypi.org/project/cli-agent-orchestrator/) via GitHub Actions. The pipeline is designed so every release goes to **TestPyPI first**, is smoke-tested, and then waits for a maintainer to approve the production publish. A release starts one of two ways: **every Monday at 09:17 UTC on its own**, when something has merged since the last release, or **by hand**. Either way it stops at a tagged GitHub Release. Publishing to PyPI normally takes **two maintainers**: one starts **Publish to PyPI** from the tag, and a different one approves the PyPI upload — though the `pypi` environment's `can_admins_bypass` setting lets a repo admin approve their own run and publish alone. ## Pipeline overview ``` release.yml (weekly schedule, or manual) ├─► preflight (scripts/release_preflight.py: on main, ci.yml green at the exact │ commit, previous release complete, bump derived from the commits; │ a scheduled run REFUSES a major and hands it to a person) └─► release (bump pyproject.toml + uv.lock + devcontainer feature + changelog, run the same version check publish runs, then commit + tag + ONE atomic push, then a GitHub Release; the run summary says how to publish it) publish-to-pypi.yml (a maintainer dispatches `release` from the tag, or publishes a Release) ├─► verify-release-version (seconds: tag == pyproject.toml == uv.lock == │ devcontainer feature, and the version is on │ neither TestPyPI nor PyPI; fails BEFORE the builds) ├─► build-wheels / build-sdist (per-platform wheels + one sdist, Web UI bundled) ├─► publish-testpypi (environment: testpypi, OIDC) ├─► smoke-test (install from TestPyPI, verify entry points, run `cao tui`) └─► publish-pypi (environment: pypi — MAINTAINER APPROVAL GATE) ``` `verify-release-version` exists because v2.5.1, v2.5.2 and v2.5.4 were each tagged on a commit that had not been bumped, built already-published filenames for ~80 minutes, and then failed at TestPyPI with `400 File already exists`. It runs `scripts/assert_release_version.py`, whose failure text names the remedy for the situation it found. On the release chain it also runs `make check-agui-trace-release`, which refuses a missing or stale CAO Dojo trace. **Release** runs both checks before it tags, so a tree they would refuse never becomes a tag and a GitHub Release. Authentication uses [PyPI Trusted Publishing (OIDC)](https://docs.pypi.org/trusted-publishers/) — no API token secrets are stored in GitHub. --- ## One-time setup (maintainer, per project) ### 1. Configure Trusted Publishers **PyPI:** 1. Go to https://pypi.org/manage/account/publishing/ 2. "Add a new pending publisher" with: - PyPI project name: `cli-agent-orchestrator` - Owner: `awslabs` - Repository: `cli-agent-orchestrator` - Workflow: `publish-to-pypi.yml` - Environment: `pypi` **TestPyPI:** 1. Go to https://test.pypi.org/manage/account/publishing/ 2. Same values, but environment: `testpypi` ### 2. Configure GitHub Environments In GitHub: **Settings → Environments**. **`testpypi`** — no restrictions. (Smoke-test runs here; no approval needed.) **`pypi`** — this is the approval gate: - **Required reviewers:** add the maintainer team / usernames who can approve prod releases. - **Deployment branches and tags:** restrict to tags matching `v*` so only tagged releases can promote to prod. > **The live setting differs (read 2026-11-02):** the `pypi` policy admits the `main` > branch as well as `v*` tags. The `release` chain does not rely on it: its > `verify-release-version` step refuses any ref that is not a tag. The `pypi` escape > hatch below can run from `main`, where only the tree and PyPI are checked. ### 3. Verify Web UI build works in CI Nothing to configure — the `build` job runs `npm ci && npm run build` in `web/` and copies `web/dist/` into `src/cli_agent_orchestrator/web_ui/` before `uv build`. The wheel artifact includes this per `[tool.hatch.build].artifacts` in `pyproject.toml`. --- ## The weekly release **Why it exists:** releases used to wait for someone to remember to cut one, and fixes, some of them security-relevant, sat unreleased on `main` for weeks (#651). **What it does, every Monday at 09:17 UTC** (UTC all year; cron does not follow daylight saving): 1. Finds the previous release: the newest `vX.Y.Z` tag on `main`. Tags such as `v2.6.0rc1` are ignored. 2. If nothing has merged since, it stops. The run is green and nothing is released. The bot's own `chore(agent-plugin): repin packages to vX.Y.Z` commit, which the publish pushes after every release, does not count as something merged. 3. Works out the version bump from the commit messages ([Conventional Commits](https://www.conventionalcommits.org/)): | The commits since the last release contain | Bump | |---|---| | a subject with `!` (`feat!: …`, `build(deps)!: …`) or a `BREAKING CHANGE:` footer | **major**: refused, see below | | a `feat:` or `feat(scope):` subject | minor | | anything else | patch | Only the **subject** and the **footer** count, which is where the spec puts these markers. A `BREAKING CHANGE:` quoted in the middle of a description, in a code block or after `>`, does not make a release major. 4. Releases: bumps, tags and creates the GitHub Release, then **stops**. The run summary says how to publish it: a maintainer dispatches **Publish to PyPI** from the new tag with `environment: release` (TestPyPI, the smoke test, then the PyPI upload), and a **different** maintainer approves the upload. The `pypi` environment will not let the one who dispatched approve their own run. Until that release is on PyPI, the next Monday refuses ("not verifiably on PyPI"), so an unpublished release is never skipped over. **When it refuses** (the run is red and nothing is bumped, tagged or published): | The run says | Why | What to do | |---|---|---| | `a scheduled run never cuts a major release` | A commit since the last release is marked breaking. A major is never cut with nobody watching. | If it really is breaking, run **Release** by hand with `bump=major`. Every scheduled run refuses until then. | | `carry a breaking-change marker outside the subject and the footer` | A body line looks like a breaking marker. In a squash merge it can be a real break from one of the squashed commits, so the schedule cannot tell. | Read the line in the run summary. Run **Release** by hand: `bump=major` if it is breaking, otherwise the bump the summary shows. | | `ci.yml is '…' at ` | CI is missing, still running, or red for that exact commit. | Wait for CI or fix `main`. The next Monday tries again. | | `the previous release vX.Y.Z is not a published GitHub Release` / `not verifiably on PyPI` | The last release has not been published to PyPI yet, or stopped half way. The schedule never skips past it. | Dispatch **Publish to PyPI** with `environment: release` from that tag, and have another maintainer approve; or finish or supersede it by hand. | ## Cutting a release by hand 1. Trigger **`Release`** workflow via Actions → "Run workflow" on `main`: - Pick `patch`, `minor`, or `major`. The run summary warns you if the commits call for a different bump, and if the previous release is incomplete. - It refuses to run from any branch but `main`, or on a commit whose `ci.yml` run is not green. - `release.yml` bumps `pyproject.toml`, `uv.lock` and the devcontainer feature, runs the same version check `verify-release-version` will, then commits, tags `v`, pushes both in one atomic push, and creates a GitHub Release. - The changelog is not generated from commit subjects. The bump promotes the single `## [Unreleased]` section to `## [X.Y.Z] - YYYY-MM-DD`, inserts a fresh empty `## [Unreleased]` above it, and merges validated `changelog.d/..md` fragments into the promoted section. The release commit includes the deletion of collected fragments. A missing or duplicate heading refuses the release. An empty Unreleased section is allowed because the release policy derives whether to release from commits, and changelog entries are not a preflight requirement. - If `uv lock` would change anything in `uv.lock` beyond this project's own version line, the bump refuses: the release commit goes to `main` without a PR, so it may carry the bump and nothing else. Relock `main` in a reviewed PR first. 2. A GitHub Release created by the workflow does not start **`Publish to PyPI`**: a release made with the workflow's own token triggers no workflows. Start it yourself: Actions → **Publish to PyPI** → "Run workflow", **use workflow from the tag** `v`, `environment: release`. You are then that run's actor, so another maintainer approves the PyPI step. It runs: - `verify-release-version` refuses, in seconds, a tag whose version `pyproject.toml`, `uv.lock` and the devcontainer feature do not all carry, or that TestPyPI or PyPI already serves. - `build-wheels` and `build-sdist` run (per-platform wheels + sdist with Web UI bundled). - `publish-testpypi` publishes to TestPyPI. - `smoke-test` installs from TestPyPI and runs `cao --help`, `cao-server --help`, `cao-mcp-server --help`. - `publish-pypi` **pauses** waiting for a maintainer to approve in the `pypi` environment. A required reviewer clicks **Review deployments → Approve** on the Actions run to ship to prod. ### Full release chain from a tag (`environment: release`) Runs exactly what a published GitHub Release runs: `verify-release-version` (tag, tree and both indexes), the builds, `publish-testpypi`, `smoke-test`, then `publish-pypi` behind the maintainer approval gate. This is how both the weekly release and a hand-cut release reach PyPI: a maintainer dispatches it from the `v*` tag `release.yml` pushed, and another maintainer approves. Dispatched from a branch instead of a `v*` tag, it fails in `verify-release-version`. ### Manual TestPyPI-only publish (no release) Sometimes you want to sanity-check a build without cutting a real release: 1. Actions → **Publish to PyPI** → "Run workflow" 2. Select `environment: testpypi` 3. `verify-release-version` checks that `pyproject.toml`, `uv.lock` and the devcontainer feature agree, and that this version is **not already on TestPyPI** (only TestPyPI is asked; PyPI state does not matter for this path). TestPyPI never accepts a filename twice, so a sanity-check build needs a version that has not been uploaded there before. If you dispatch from a `v*` tag, the tag is compared with the tree as well. 4. Then `build-wheels` + `build-sdist` + `publish-testpypi` run. Smoke-test and prod steps are skipped. ### Manual PyPI publish (escape hatch) If a release was cut but the auto-pipeline failed partway through and you need to retry the prod step: 1. Actions → **Publish to PyPI** → "Run workflow" 2. Select `environment: pypi` 3. Dispatch it from the `v*` tag. `verify-release-version` then compares the tag with the tree (the `pypi` environment's live policy also admits `main`, where only the tree is checked) and checks the version is not already on PyPI. Then the builds run, `publish-testpypi` + `smoke-test` are skipped (they already ran), and `publish-pypi` hits the maintainer approval gate. --- ## Troubleshooting **"pending publisher" error on first publish:** Expected. PyPI marks the publisher pending until the first successful run. After that it becomes permanent. **Smoke-test fails with "No matching distribution":** TestPyPI index can take up to a minute to propagate. The workflow sleeps 30s; if that's not enough, increase it or retry. **Approval required but button missing:** Check `Settings → Environments → pypi → Required reviewers`. You must be listed there. **`verify-release-version` fails ("tag vX.Y.Z names X.Y.Z but pyproject.toml says ..."):** The tag was placed on a commit that was not bumped. Re-running the workflow on the same tag fails the same way, because it checks out the same tree. Merge a `chore: release vX.Y.Z` PR that bumps `pyproject.toml`, `uv.lock` and `.devcontainer/features/cao/devcontainer-feature.json` together (the shape of #899), then delete the tag and its GitHub Release and re-create both on that merge commit. **Release, or `verify-release-version`, fails ("trace missing or stale"):** The published CAO Dojo AG-UI trace (`examples/ag-ui/cao-dojo/trace/cao-dojo-trace.ndjson`) is missing, or was recorded against an older committed shape file. PRs only warn about this, because re-recording needs a logged-in Claude Code. **Release** runs the same check before it tags, so in the usual case nothing was tagged: someone with Claude Code runs `make record-agui-trace` on `main`, merges the result, and runs **Release** again. If a tag and GitHub Release already exist (a tag created by hand, say), re-create them on that merge commit. The check reads two committed files and needs no server or network (`make check-agui-trace-release` reproduces it locally). A maintainer without Claude Code can still publish an already-tagged version through the `pypi` dispatch (see "Manual PyPI publish (escape hatch)"): the trace check runs only on the release chain, not on the `testpypi` or `pypi` dispatches. That publishes with the stale trace, so record it before the next release. **`verify-release-version` fails ("... is already on https://test.pypi.org"):** An earlier run of this version reached TestPyPI before failing later in the pipeline. Neither index accepts a filename twice, so the version is spent: bump to the next patch version through a `chore: release` PR and re-create the tag and Release on it. **Release preflight refuses a major, or a marker outside a subject or footer:** See the table under "The weekly release". The schedule will not guess; run **Release** by hand with the bump you intend. **Release fails at "Bump version and promote the changelog" with "`uv lock` changed N line(s) of uv.lock beyond the cli-agent-orchestrator version":** The uv on the runner would rewrite more of the lock than the version line, usually because the lock was written by a different uv. Nothing was committed. Relock `main` in a reviewed PR with the uv CI uses (`uv lock`, then check the diff), then release again.