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.

Merge branch 'ci/release-automation' of https://github.com/JerrettDavis/headroom into ci/release-automation

JerrettDavisaf7d6b74303b
diff --cc .github/workflows/release.yml
index 2ca4fd583,6f47e15a0..98f5db306
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@@ -1,305 -1,283 +1,311 @@@
-name: Release
-
-# ─── Package Registry Configuration ────────────────────────────────────────────
-# Edit these constants to change package names, environments, and registries.
-# All values are referenced via ${{ env.VAR }} throughout the workflow.
-env:
- # PyPI
- PYPI_PACKAGE: headroom-ai
- PYPI_ENVIRONMENT: pypi
-
- # npm (npmjs.org)
- NPM_REGISTRY_URL: https://registry.npmjs.org
- NPM_SDK_PACKAGE: headroom-ai
- NPM_OPENCLAW_PACKAGE: headroom-openclaw
-
- # GitHub Package Registry
- GITHUB_PACKAGES_REGISTRY_URL: https://npm.pkg.github.com
-
- # ─── Safety Gates ──────────────────────────────────────────────────────────────
- # Set to 'true' to skip a publish target (e.g., when tokens are not configured).
- # In GitHub: repo Settings → Variables → Actions Variables → New repository variable.
- # Locally via act: pass -e event.yml or set in .actrc.local (see .actrc.example).
- PYPI_SKIP: "false"
- NPM_SKIP: "false"
- GITHUB_PKG_SKIP: "false"
-
-on:
- push:
- branches: [main]
- workflow_dispatch:
- inputs:
- version:
- description: "Manual version override"
- required: false
- dry_run:
- description: "Skip publish"
- type: boolean
- default: false
-
-jobs:
- detect-version:
- runs-on: ubuntu-latest
- outputs:
- level: ${{ steps.bump.outputs.level }}
- version: ${{ steps.ver.outputs.version }}
- is_release: ${{ steps.ver.outputs.is_release }}
- previous_tag: ${{ steps.bump.outputs.previous_tag }}
- commit_message: ${{ steps.bump.outputs.commit_message }}
- steps:
- - uses: actions/checkout@v4
- with:
- fetch-depth: 0
-
- - name: Detect bump level
- id: bump
- run: |
- python - <<'PYEOF'
- import subprocess, os, re, tomllib, sys
-
- # Get latest commit message and body
- msg = subprocess.run(["git", "log", "-1", "--format=%s"], capture_output=True, text=True, check=False).stdout.strip()
- body = subprocess.run(["git", "log", "-1", "--format=%B"], capture_output=True, text=True, check=False).stdout.strip()
-
- # Get previous tag, fall back to version from pyproject.toml
- tag_result = subprocess.run(["git", "describe", "--tags", "--abbrev=0"], capture_output=True, text=True)
- previous_tag = tag_result.stdout.strip() if tag_result.returncode == 0 else ""
- if not previous_tag:
- with open("pyproject.toml", "rb") as f:
- previous_tag = "v" + tomllib.load(f)["project"]["version"]
-
- # Determine bump level
- is_major = bool(re.search(r'^feat!', msg)) or "BREAKING CHANGE" in body
- is_minor = bool(re.search(r'^feat:', msg)) and not is_major
- level = "major" if is_major else ("minor" if is_minor else "patch")
-
- with open(os.environ["GITHUB_OUTPUT"], "a") as f:
- f.write(f"commit_message={msg}\n")
- f.write(f"previous_tag={previous_tag}\n")
- f.write(f"level={level}\n")
- PYEOF
-
- - name: Compute version
- id: ver
- run: |
- python - <<'PYEOF'
- import os, re, tomllib
-
- with open("pyproject.toml", "rb") as f:
- data = tomllib.load(f)
- current = data["project"]["version"]
- major, minor, patch = map(int, re.match(r"(\d+)\.(\d+)\.(\d+)", current).groups())
-
- level = os.environ.get("LEVEL", "patch")
- if level == "major":
- new_ver = f"{major + 1}.0.0"
- elif level == "minor":
- new_ver = f"{major}.{minor + 1}.0"
- else:
- new_ver = f"{major}.{minor}.{patch + 1}"
-
- manual = os.environ.get("MANUAL_VER", "")
- if manual:
- new_ver = manual
-
- with open(os.environ["GITHUB_OUTPUT"], "a") as f:
- f.write(f"version={new_ver}\n")
- f.write("is_release=true\n")
- PYEOF
- env:
- LEVEL: ${{ needs.detect-version.outputs.level }}
- MANUAL_VER: ${{ github.event.inputs.version }}
-
- build:
- needs: [detect-version]
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v4
- with:
- fetch-depth: 0
-
- - name: Set up Python
- uses: actions/setup-python@v5
- with:
- python-version: "3.12"
-
- - name: Run version sync
- run: |
- python scripts/version-sync.py --version ${{ needs.detect-version.outputs.version }}
-
- - name: Commit version bump
- run: |
- python - <<'PYEOF'
- import subprocess, os
-
- ver = os.environ["VERSION"]
-
- def run(cmd, **kwargs):
- result = subprocess.run(cmd, **kwargs)
- if result.returncode != 0:
- print(f"WARNING: {' '.join(cmd)} exited {result.returncode}", file=os.sys.stderr)
- return result
-
- run(["git", "config", "user.name", "github-actions[bot]"])
- run(["git", "config", "user.email", "github-actions[bot]@users.noreply.github.com"])
- run(["git", "add", "-A"])
- result = run(["git", "commit", "-m", f"chore: bump version to {ver}"], capture_output=True)
- if result.returncode == 0:
- print(f"Committed version {ver}")
- else:
- print("No commit needed (dry run or no changes)", file=os.sys.stderr)
- PYEOF
- env:
- VERSION: ${{ needs.detect-version.outputs.version }}
-
- - name: Run changelog generation
- run: |
- python scripts/changelog-gen.py \
- --version ${{ needs.detect-version.outputs.version }} \
- --since ${{ needs.detect-version.outputs.previous_tag }}
-
- - name: Show changelog
- run: cat .changelog.md
-
- - name: Upload changelog artifact
- uses: actions/upload-artifact@v4
- with:
- name: changelog
- path: ${{ github.workspace }}/.changelog.md
-
- - name: Build Python package
- run: python -m pip install build wheel && python -m build
-
- - name: Upload dist artifact
- uses: actions/upload-artifact@v4
- with:
- name: dist
- path: ${{ github.workspace }}/dist/
-
- publish-pypi:
- needs: [build]
- if: github.event.inputs.dry_run != 'true' && vars.PYPI_SKIP != 'true'
- environment: pypi # NOTE: environment name must be a literal; update here if the GitHub environment name changes
- runs-on: ubuntu-latest
- steps:
- - name: Download dist artifact
- uses: actions/download-artifact@v4
- with:
- name: dist
- path: dist/
-
- - name: Publish ${{ env.PYPI_PACKAGE }} to PyPI
- uses: pypa/gh-action-pypi-publish@release/v1
-
- publish-npm:
- needs: [build]
- if: github.event.inputs.dry_run != 'true' && vars.NPM_SKIP != 'true'
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v4
- with:
- fetch-depth: 0
-
- - name: Set up Node.js
- uses: actions/setup-node@v4
- with:
- node-version: "20"
- registry-url: ${{ env.NPM_REGISTRY_URL }}
-
- - name: Download dist artifact
- uses: actions/download-artifact@v4
- with:
- name: dist
- path: dist/
-
- - name: Publish ${{ env.NPM_SDK_PACKAGE }} (TypeScript SDK) to npmjs.org
- env:
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- run: |
- cd sdk/typescript
- npm install
- npm version ${{ needs.detect-version.outputs.version }} --no-git-tag-version
- npm publish --access public
-
- - name: Publish ${{ env.NPM_OPENCLAW_PACKAGE }} to npmjs.org
- env:
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- run: |
- cd plugins/openclaw
- npm install
- npm version ${{ needs.detect-version.outputs.version }} --no-git-tag-version
- npm publish --access public
-
- publish-github-packages:
- needs: [build]
- if: github.event.inputs.dry_run != 'true' && vars.GITHUB_PKG_SKIP != 'true'
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v4
- with:
- fetch-depth: 0
-
- - name: Set up Node.js for GitHub Package Registry
- uses: actions/setup-node@v4
- with:
- node-version: "20"
- registry-url: ${{ env.GITHUB_PACKAGES_REGISTRY_URL }}
-
- - name: Download dist artifact
- uses: actions/download-artifact@v4
- with:
- name: dist
- path: dist/
-
- - name: Publish ${{ env.NPM_OPENCLAW_PACKAGE }} to GitHub Package Registry
- env:
- NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: |
- cd plugins/openclaw
- npm install
- npm version ${{ needs.detect-version.outputs.version }} --no-git-tag-version
- npm publish --access public
-
- create-release:
- needs: [detect-version, build, publish-npm, publish-github-packages]
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v4
- with:
- fetch-depth: 0
-
- - name: Download changelog artifact
- uses: actions/download-artifact@v4
- with:
- name: changelog
- path: .
-
- - name: Create GitHub Release
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: |
- gh release create v${{ needs.detect-version.outputs.version }} \
- --title "Release v${{ needs.detect-version.outputs.version }}" \
- --notes-file .changelog.md
+name: Release
+
+# ─── Package Registry Configuration ────────────────────────────────────────────
+# Edit these constants to change package names, environments, and registries.
+# All values are referenced via ${{ env.VAR }} throughout the workflow.
+env:
+ # PyPI
+ PYPI_PACKAGE: headroom-ai
+ PYPI_ENVIRONMENT: pypi
+
+ # npm (npmjs.org)
+ NPM_REGISTRY_URL: https://registry.npmjs.org
+ NPM_SDK_PACKAGE: headroom-ai
+ NPM_OPENCLAW_PACKAGE: headroom-openclaw
+
+ # GitHub Package Registry
+ GITHUB_PACKAGES_REGISTRY_URL: https://npm.pkg.github.com
+
+ # ─── Safety Gates ──────────────────────────────────────────────────────────────
+ # Set to 'true' to skip a publish target (e.g., when tokens are not configured).
+ # In GitHub: repo Settings → Variables → Actions Variables → New repository variable.
+ # Locally via act: pass -e event.yml or set in .actrc.local (see .actrc.example).
+ PYPI_SKIP: "false"
+ NPM_SKIP: "false"
+ GITHUB_PKG_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/**"
+ workflow_dispatch:
+ inputs:
+ version:
+ description: "Manual version override"
+ required: false
+ dry_run:
+ description: "Skip publish"
+ type: boolean
+ default: false
+
+jobs:
+ detect-version:
+ runs-on: ubuntu-latest
+ outputs:
+ version: ${{ steps.ver.outputs.version }}
+ npm_version: ${{ steps.ver.outputs.npm_version }}
+ canonical: ${{ steps.ver.outputs.canonical }}
+ height: ${{ steps.ver.outputs.height }}
+ bump: ${{ steps.ver.outputs.bump }}
+ previous_tag: ${{ steps.ver.outputs.previous_tag }}
+ commit_message: ${{ steps.bump.outputs.commit_message }}
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+
+ - name: Detect bump level
+ id: bump
+ run: |
+ python - <<'PYEOF'
+ import subprocess, os, re
+
+ msg = subprocess.run(["git", "log", "-1", "--format=%s"], capture_output=True, text=True, check=False).stdout.strip()
+ body = subprocess.run(["git", "log", "-1", "--format=%B"], capture_output=True, text=True, check=False).stdout.strip()
+
+ is_major = bool(re.search(r'^feat!', msg)) or "BREAKING CHANGE" in body
+ is_minor = bool(re.search(r'^feat:', msg)) and not is_major
+ level = "major" if is_major else ("minor" if is_minor else "patch")
+
+ with open(os.environ["GITHUB_OUTPUT"], "a") as f:
+ f.write(f"commit_message={msg}\n")
+ f.write(f"level={level}\n")
+ PYEOF
+
+ - name: Compute version from canonical + commit height
+ id: ver
+ run: |
+ python - <<'PYEOF'
+ import subprocess, os, re, tomllib
+
+ with open("pyproject.toml", "rb") as f:
+ data = tomllib.load(f)
+ canonical = data["project"]["version"]
- major, minor, patch = map(int, re.match(r"(\d+)\.(\d+)\.(\d+)", canonical).groups()
++ major, minor, patch = map(int, re.match(r"(\d+)\.(\d+)\.(\d+)", canonical).groups())
+
+ level = os.environ.get("LEVEL", "patch")
+ manual = os.environ.get("MANUAL_VER", "")
+
+ if manual:
+ new_ver = manual
+ bump = "manual"
++ npm_ver = manual
++ canonical_out = ""
++ height_out = "0"
++ previous_tag_out = ""
+ else:
+ # Find last tag matching v{canonical}.*
+ tag_prefix = f"v{canonical}."
+ tag_result = subprocess.run(
+ ["git", "tag", "-l", f"{tag_prefix}*"],
+ capture_output=True, text=True, check=False
+ )
+ tags = [t.strip() for t in tag_result.stdout.strip().split("\n") if t.strip()]
+
+ if tags:
+ # Sort by version number, get highest
+ def parse_tag(t):
+ v = t.lstrip("v")
+ parts = re.match(r"(\d+)\.(\d+)\.(\d+)\.(\d+)", v)
+ return tuple(int(x) for x in parts.groups()) if parts else (0, 0, 0, 0)
+ tags.sort(key=parse_tag, reverse=True)
+ last_tag = tags[0]
+ prev_height = int(last_tag.rsplit(".", 1)[-1])
+
+ # Count commits since the last tagged release
+ count_result = subprocess.run(
+ ["git", "rev-list", f"{last_tag}..HEAD", "--count"],
+ capture_output=True, text=True, check=False
+ )
+ height = int(count_result.stdout.strip())
+ else:
+ # No prior tag at this canonical level — height = 0
+ prev_height = 0
+ height = 0
+
+ # Determine bump
+ if level == "major":
+ new_ver = f"{major + 1}.0.0.0"
+ npm_ver = f"{major + 1}.0.0"
+ elif level == "minor":
+ new_ver = f"{major}.{minor + 1}.0.0"
+ npm_ver = f"{major}.{minor + 1}.0"
+ else: # patch
- if prev_height > 0:
- new_ver = f"{canonical}.{prev_height}"
- npm_ver = f"{major}.{minor}.{patch + 1}"
- else:
- new_ver = f"{canonical}.0"
- npm_ver = canonical
++ new_ver = f"{canonical}.{prev_height + 1}"
++ npm_ver = f"{major}.{minor}.{patch + 1}"
+
+ bump = level
+
+ with open(os.environ["GITHUB_OUTPUT"], "a") as f:
+ f.write(f"version={new_ver}\n")
+ f.write(f"npm_version={npm_ver}\n")
- f.write(f"canonical={canonical}\n")
- f.write(f"height={height}\n")
++ f.write(f"canonical={canonical_out if manual else canonical}\n")
++ f.write(f"height={height_out if manual else height}\n")
+ f.write(f"bump={bump}\n")
- f.write(f"previous_tag={last_tag if tags else ''}\n")
++ f.write(f"previous_tag={previous_tag_out if manual else (last_tag if tags else '')}\n")
+ PYEOF
+ env:
- LEVEL: ${{ needs.detect-version.outputs.level }}
++ LEVEL: ${{ steps.bump.outputs.level }}
+ MANUAL_VER: ${{ github.event.inputs.version }}
+
+ build:
+ needs: [detect-version]
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+
+ - name: Set up Python
+ uses: actions/setup-python@v5
+ with:
+ python-version: "3.12"
+
+ - name: Sync version to package files
+ run: |
+ python scripts/version-sync.py --version ${{ needs.detect-version.outputs.npm_version }}
+
+ - name: Run changelog generation
+ run: |
- python scripts/changelog-gen.py \
- --version ${{ needs.detect-version.outputs.version }} \
- --since ${{ needs.detect-version.outputs.previous_tag }}
++ PREV_TAG="${{ needs.detect-version.outputs.previous_tag }}"
++ if [ -n "$PREV_TAG" ]; then
++ python scripts/changelog-gen.py \
++ --version ${{ needs.detect-version.outputs.version }} \
++ --since "$PREV_TAG"
++ else
++ python scripts/changelog-gen.py \
++ --version ${{ needs.detect-version.outputs.version }}
++ fi
+
+ - name: Show changelog
+ run: cat .changelog.md
+
+ - name: Upload changelog artifact
+ uses: actions/upload-artifact@v4
+ with:
+ name: changelog
+ path: .changelog.md
+
+ - name: Build Python package
+ run: python -m pip install build wheel && python -m build
+
+ - name: Upload dist artifact
+ uses: actions/upload-artifact@v4
+ with:
+ name: dist
+ path: dist/
+
+ publish-pypi:
+ needs: [build]
+ if: github.event.inputs.dry_run != 'true' && vars.PYPI_SKIP != 'true'
+ environment: pypi # NOTE: environment name must be a literal; update here if the GitHub environment name changes
+ runs-on: ubuntu-latest
+ steps:
+ - name: Download dist artifact
+ uses: actions/download-artifact@v4
+ with:
+ name: dist
+ path: dist/
+
+ - name: Publish ${{ env.PYPI_PACKAGE }} to PyPI
+ uses: pypa/gh-action-pypi-publish@release/v1
+
+ publish-npm:
+ needs: [build]
+ if: github.event.inputs.dry_run != 'true' && vars.NPM_SKIP != 'true'
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+
+ - name: Set up Node.js
+ uses: actions/setup-node@v4
+ with:
+ node-version: "20"
+ registry-url: ${{ env.NPM_REGISTRY_URL }}
+
+ - name: Download dist artifact
+ uses: actions/download-artifact@v4
+ with:
+ name: dist
+ path: dist/
+
+ - name: Publish ${{ env.NPM_SDK_PACKAGE }} (TypeScript SDK) to npmjs.org
+ env:
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
+ run: |
+ cd sdk/typescript
+ npm install
+ npm version ${{ needs.detect-version.outputs.npm_version }} --no-git-tag-version
+ npm publish --access public
+
+ - name: Publish ${{ env.NPM_OPENCLAW_PACKAGE }} to npmjs.org
+ env:
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
+ run: |
+ cd plugins/openclaw
+ npm install
+ npm version ${{ needs.detect-version.outputs.npm_version }} --no-git-tag-version
+ npm publish --access public
+
+ publish-github-packages:
+ needs: [build]
+ if: github.event.inputs.dry_run != 'true' && vars.GITHUB_PKG_SKIP != 'true'
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+
+ - name: Set up Node.js for GitHub Package Registry
+ uses: actions/setup-node@v4
+ with:
+ node-version: "20"
+ registry-url: ${{ env.GITHUB_PACKAGES_REGISTRY_URL }}
+
+ - name: Download dist artifact
+ uses: actions/download-artifact@v4
+ with:
+ name: dist
+ path: dist/
+
+ - name: Publish ${{ env.NPM_OPENCLAW_PACKAGE }} to GitHub Package Registry
+ env:
+ NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ run: |
+ cd plugins/openclaw
+ npm install
+ npm version ${{ needs.detect-version.outputs.npm_version }} --no-git-tag-version
+ npm publish --access public
+
+ create-release:
+ needs: [detect-version, build]
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+
+ - name: Download changelog artifact
+ uses: actions/download-artifact@v4
+ with:
+ name: changelog
+ path: .
+
+ - name: Create GitHub Release
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ run: |
+ gh release create v${{ needs.detect-version.outputs.version }} \
+ --title "Release v${{ needs.detect-version.outputs.version }}" \
+ --notes-file .changelog.md