Skip to content

Compress tool outputs, logs, files, and RAG chunks before they reach the LLM. 20% fewer tokens for coding agents, 60-95% fewer tokens for JSON, same answers. Library, proxy, MCP server.

ci(release): adopt release-please for gated publishes

chopratejasc8e347f1ac33
diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml
new file mode 100644
index 000000000..2545f5043
--- /dev/null
+++ b/.github/workflows/release-please.yml
@@ -0,0 +1,49 @@
+name: Release Please
+
+# What this does
+# ----------------
+# release-please watches `main` for conventional-commit traffic and
+# maintains a single "Release vX.Y.Z" PR that aggregates everything
+# released since the last tag. Merging that PR is what triggers an
+# actual PyPI / npm / GitHub-Release publish (via release.yml, which
+# fires on the published-release event the bot emits at merge time).
+#
+# This replaces the prior "every push to main is a release" pattern
+# that burned PyPI's per-project storage quota by uploading a fresh
+# wheel matrix (~200 MB) for each merged `fix:` / `feat:` PR.
+#
+# Day-to-day:
+# - Merge a `fix:` PR into main -> bot updates the release PR
+# - Merge a `feat:` PR into main -> bot bumps minor in release PR
+# - Merge `ci:` / `docs:` / `chore:` -> no PR change (hidden)
+# - Ready to ship -> merge the release PR
+# (bot tags + emits release event;
+# release.yml does the actual builds + publishes)
+#
+# Config lives in `.release-please-config.json`; current versions
+# tracked in `.release-please-manifest.json`.
+
+on:
+ push:
+ branches: [main]
+
+permissions:
+ contents: write
+ pull-requests: write
+
+concurrency:
+ # Serialize bot runs on main so two pushes don't race the
+ # release-PR update. We never cancel mid-flight — losing a manifest
+ # write would mean the next push computes the wrong base version.
+ group: release-please-${{ github.ref }}
+ cancel-in-progress: false
+
+jobs:
+ release-please:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: googleapis/release-please-action@v4
+ with:
+ token: ${{ secrets.GITHUB_TOKEN }}
+ config-file: .release-please-config.json
+ manifest-file: .release-please-manifest.json
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 3b43b828d..5dcd8218b 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -25,18 +25,15 @@ env:
GH_PACKAGES_SKIP: "false"
on:
- push:
- branches: [main]
- paths-ignore:
- - "docs/**"
- - ".github/workflows/ci.yml"
- - ".github/workflows/publish.yml"
- - "scripts/**"
- - ".commitlintrc.json"
- - ".actrc"
- - ".actrc.local.example"
- - ".env.act.example"
- - ".github/act/**"
+ # Triggered when release-please's release PR is merged: the bot
+ # tags the merge commit `vX.Y.Z` and creates a GitHub Release on
+ # that tag, which fires the `release: published` event. Ordinary
+ # pushes to main no longer trigger publishes — that was the old
+ # behavior that burned PyPI's per-project storage quota by
+ # uploading a fresh wheel matrix (~200 MB) per merged fix/feat PR.
+ # See .github/workflows/release-please.yml for the PR-aggregator.
+ release:
+ types: [published]
# X2: PR-time release dry-run. Trigger on PRs that touch release-
# critical paths so the wheel matrix + smoke-import gate run BEFORE
# merge — not after the tag is pushed and main is broken. Path
@@ -91,12 +88,35 @@ jobs:
with:
fetch-depth: 0
+ # When fired by release-please's release event, the tag the
+ # bot just published IS the canonical version for this run —
+ # release_version.py's git-log derivation would re-bump it.
+ # workflow_dispatch still honors `inputs.version`; PR dry-runs
+ # leave MANUAL_VER empty and the script computes normally.
+ - name: Resolve MANUAL_VER from trigger
+ id: manualver
+ shell: bash
+ env:
+ RELEASE_TAG: ${{ github.event.release.tag_name }}
+ MANUAL_INPUT: ${{ github.event.inputs.version }}
+ run: |
+ if [ "${{ github.event_name }}" = "release" ]; then
+ # github.event.release.tag_name is "vX.Y.Z" — strip the
+ # leading "v" so release_version.py's SemVer parser
+ # accepts it.
+ echo "value=${RELEASE_TAG#v}" >> "$GITHUB_OUTPUT"
+ elif [ -n "$MANUAL_INPUT" ]; then
+ echo "value=$MANUAL_INPUT" >> "$GITHUB_OUTPUT"
+ else
+ echo "value=" >> "$GITHUB_OUTPUT"
+ fi
+
- name: Compute semantic version from canonical + release history
id: ver
run: |
python headroom/release_version.py
env:
- MANUAL_VER: ${{ github.event.inputs.version }}
+ MANUAL_VER: ${{ steps.manualver.outputs.value }}
# Single source of truth for changelog + npm packaging. Wheels are
# built per-platform in `build-wheels` below. publish-pypi merges them.
@@ -888,7 +908,13 @@ jobs:
TAG="v${{ needs.detect-version.outputs.version }}"
TITLE="Release v${{ needs.detect-version.outputs.version }}"
if gh release view "$TAG" > /dev/null 2>&1; then
- gh release edit "$TAG" --title "$TITLE" --notes-file .changelog.md
+ # Release already exists — typically created by
+ # release-please on release-PR merge with an auto-
+ # generated changelog body. Don't overwrite its notes
+ # (--notes-file would clobber them); only sync the
+ # title in case detect-version's canonical form differs
+ # from what the bot set.
+ gh release edit "$TAG" --title "$TITLE"
else
gh release create "$TAG" --title "$TITLE" --notes-file .changelog.md
fi
diff --git a/.release-please-config.json b/.release-please-config.json
new file mode 100644
index 000000000..efe62fb45
--- /dev/null
+++ b/.release-please-config.json
@@ -0,0 +1,42 @@
+{
+ "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
+ "release-type": "python",
+ "include-v-in-tag": true,
+ "bump-minor-pre-major": true,
+ "bump-patch-for-minor-pre-major": false,
+ "draft": false,
+ "prerelease": false,
+ "separate-pull-requests": false,
+ "packages": {
+ ".": {
+ "package-name": "headroom-ai",
+ "release-type": "python",
+ "extra-files": [
+ {
+ "type": "json",
+ "path": "sdk/typescript/package.json",
+ "jsonpath": "$.version"
+ },
+ {
+ "type": "json",
+ "path": "plugins/openclaw/package.json",
+ "jsonpath": "$.version"
+ }
+ ]
+ }
+ },
+ "changelog-sections": [
+ { "type": "feat", "section": "Features" },
+ { "type": "fix", "section": "Bug Fixes" },
+ { "type": "perf", "section": "Performance Improvements" },
+ { "type": "deps", "section": "Dependencies" },
+ { "type": "revert", "section": "Reverts" },
+ { "type": "refactor", "section": "Code Refactoring" },
+ { "type": "ci", "section": "Continuous Integration", "hidden": true },
+ { "type": "build", "section": "Build System", "hidden": true },
+ { "type": "chore", "section": "Miscellaneous Chores", "hidden": true },
+ { "type": "docs", "section": "Documentation", "hidden": true },
+ { "type": "style", "section": "Styles", "hidden": true },
+ { "type": "test", "section": "Tests", "hidden": true }
+ ]
+}
diff --git a/.release-please-manifest.json b/.release-please-manifest.json
new file mode 100644
index 000000000..b28fea992
--- /dev/null
+++ b/.release-please-manifest.json
@@ -0,0 +1,3 @@
+{
+ ".": "0.9.1"
+}
diff --git a/tests/test_release_workflows.py b/tests/test_release_workflows.py
index ffeb0c394..9d872fab2 100644
--- a/tests/test_release_workflows.py
+++ b/tests/test_release_workflows.py
@@ -916,3 +916,153 @@ def test_release_workflow_runs_dry_run_on_pull_request() -> None:
"must not be cancelled — partial PyPI/Docker state is worse than "
"a slow CI queue)."
)
+
+
+def test_release_yml_triggers_on_release_published_not_every_push_to_main() -> None:
+ """release.yml fires when release-please publishes a release, not per main push.
+
+ The prior trigger (`push: branches: [main]`) caused a fresh wheel
+ matrix to be uploaded to PyPI for every merged `fix:`/`feat:` PR.
+ PyPI enforces a 10 GiB per-project storage quota and the project
+ breached it in May 2026 (publish-pypi failing on every main merge
+ from PR #482 forward). The fix routes releases through
+ release-please's release-PR pattern: bot opens/maintains a
+ `chore: release vX.Y.Z` PR aggregating conventional-commit traffic;
+ merging that PR creates the tag + GitHub Release; THAT release
+ event is what triggers this workflow.
+
+ Reverting to a per-push trigger would re-create the quota
+ blowup. This test fails any refactor that does so silently.
+ """
+ content = (ROOT / ".github" / "workflows" / "release.yml").read_text(encoding="utf-8")
+ on_block_end = content.index("\nconcurrency:")
+ on_block = content[:on_block_end]
+
+ assert "\n release:\n types: [published]" in on_block, (
+ "release.yml must trigger on the `release: published` event so "
+ "release-please's release-PR merge is the only way to publish — "
+ "see .github/workflows/release-please.yml."
+ )
+ assert "\n push:\n branches: [main]" not in on_block, (
+ "release.yml MUST NOT trigger on every push to main. That pattern "
+ "burned PyPI's 10 GiB storage quota (one fresh wheel matrix per "
+ "merged PR). Route releases through release-please instead."
+ )
+
+
+def test_release_yml_resolves_manual_ver_from_release_tag() -> None:
+ """When fired by release event, MANUAL_VER must come from the release tag.
+
+ release_version.py defaults to deriving the next version from git
+ log + canonical pyproject.toml version. On a release-published
+ run, that derivation would re-bump past the version the bot just
+ tagged, producing wheels for the wrong version. The detect-version
+ job must read `github.event.release.tag_name` and strip the leading
+ `v` so the SemVer parser accepts it.
+ """
+ content = (ROOT / ".github" / "workflows" / "release.yml").read_text(encoding="utf-8")
+
+ assert "Resolve MANUAL_VER from trigger" in content, (
+ "detect-version must include a step that resolves MANUAL_VER from "
+ "the trigger context (release.tag_name on release events; "
+ "inputs.version on workflow_dispatch)."
+ )
+ assert "RELEASE_TAG: ${{ github.event.release.tag_name }}" in content, (
+ "Resolver must read the tag from github.event.release.tag_name."
+ )
+ assert "${RELEASE_TAG#v}" in content, (
+ "Resolver must strip the leading 'v' from the release tag — "
+ "release_version.py's SemVer regex rejects 'v0.9.2'."
+ )
+ assert "MANUAL_VER: ${{ steps.manualver.outputs.value }}" in content, (
+ "Compute-version step must consume the resolver's output."
+ )
+
+
+def test_release_yml_preserves_release_please_notes_when_release_exists() -> None:
+ """create-release must not clobber release-please's auto-generated notes.
+
+ release-please creates the GitHub Release with an auto-generated
+ changelog body when its release PR merges. If create-release then
+ runs `gh release edit --notes-file .changelog.md`, the bot's
+ changelog gets overwritten with this workflow's full-history
+ fallback (which has no `--since` bound when MANUAL_VER is set
+ and previous_tag comes back empty). Keep the bot's notes intact;
+ only update title.
+ """
+ content = (ROOT / ".github" / "workflows" / "release.yml").read_text(encoding="utf-8")
+ create_release_idx = content.index("\n create-release:")
+ create_release_block = content[create_release_idx:]
+
+ assert 'gh release edit "$TAG" --title "$TITLE"\n' in create_release_block, (
+ "When the release already exists (release-please case), the edit "
+ "must only sync title — NOT pass --notes-file, which would "
+ "clobber the bot's auto-generated changelog."
+ )
+
+
+def test_release_please_workflow_exists_and_targets_main() -> None:
+ """The release-please bot workflow must be present and watch main."""
+ rp_path = ROOT / ".github" / "workflows" / "release-please.yml"
+ assert rp_path.exists(), (
+ "release-please.yml is the bot that opens/maintains the release "
+ "PR. Without it, no release ever fires (release.yml now only "
+ "triggers on the release event the bot emits)."
+ )
+
+ content = rp_path.read_text(encoding="utf-8")
+ assert "googleapis/release-please-action@v4" in content, (
+ "release-please.yml must use the v4 action — earlier versions "
+ "have different manifest semantics."
+ )
+ assert "branches: [main]" in content, (
+ "release-please.yml must watch main; that's where the bot reads "
+ "conventional-commit traffic to compute version bumps."
+ )
+ assert "config-file: .release-please-config.json" in content
+ assert "manifest-file: .release-please-manifest.json" in content
+ assert "pull-requests: write" in content, (
+ "Bot needs write permission to open/update its release PR."
+ )
+ assert "contents: write" in content, (
+ "Bot needs contents write to tag the release commit on merge."
+ )
+
+
+def test_release_please_config_and_manifest_are_present_and_consistent() -> None:
+ """Config and manifest must agree with pyproject.toml's version."""
+ import json
+
+ import tomllib
+
+ manifest = json.loads((ROOT / ".release-please-manifest.json").read_text(encoding="utf-8"))
+ config = json.loads((ROOT / ".release-please-config.json").read_text(encoding="utf-8"))
+ pyproject = tomllib.loads((ROOT / "pyproject.toml").read_text(encoding="utf-8"))
+
+ # Manifest tracks current version per package; the root package must
+ # match pyproject.toml exactly. A drift here means the bot will
+ # propose a version bump from the wrong base.
+ assert manifest["."] == pyproject["project"]["version"], (
+ f"manifest['.'] ({manifest['.']}) must match "
+ f"pyproject.toml version ({pyproject['project']['version']}). "
+ "Update the manifest when you bump pyproject.toml manually, or "
+ "let release-please own both."
+ )
+
+ # Config: the root package must declare python release-type so the
+ # bot updates pyproject.toml.
+ root_pkg = config["packages"]["."]
+ assert root_pkg["release-type"] == "python"
+ assert root_pkg["package-name"] == "headroom-ai"
+
+ # extra-files: TypeScript SDK and openclaw plugin package.json
+ # files must be in lockstep with pyproject.toml.
+ extra_paths = {ef["path"] for ef in root_pkg.get("extra-files", [])}
+ assert "sdk/typescript/package.json" in extra_paths, (
+ "release-please must bump sdk/typescript/package.json so the npm "
+ "publish in release.yml ships the same version as the wheel."
+ )
+ assert "plugins/openclaw/package.json" in extra_paths, (
+ "release-please must bump plugins/openclaw/package.json so the "
+ "openclaw npm publish stays in sync."
+ )