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.
Python agentaianthropicclaude-codecompressioncontext-engineeringcontext-windowcursorfastapilangchainllmmcpopenaiprompt-engineeringproxypythonragtoken-optimizationtokenstypescript
fix: complete fork-friendly release publishing
JerrettDavisd239e6f41f77
diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.ymlindex b9c7645d0..edd29d862 100644--- a/.github/workflows/docker.yml+++ b/.github/workflows/docker.yml@@ -1,139 +1,144 @@-name: Docker--on:- workflow_call:- inputs:- version:- description: "Version to stamp into the image contents and exact image tag"- required: false- type: string- enable_ref_tags:- description: "Whether to emit branch/PR ref tags"- required: false- default: true- type: boolean- workflow_dispatch:- inputs:- version:- description: "Version to stamp into the image contents and exact image tag"- required: false- release:- types: [published]--env:- REGISTRY: ghcr.io- IMAGE_NAME: ${{ github.repository }}--permissions:- contents: read- packages: write- id-token: write # For cosign keyless signing via Sigstore OIDC--jobs:- docker-variant-tags:- runs-on: ubuntu-latest- strategy:- fail-fast: false- matrix:- include:- - variant: ""- bake_target: runtime- - variant: nonroot- bake_target: runtime-nonroot- - variant: code- bake_target: runtime-code- - variant: code-nonroot- bake_target: runtime-code-nonroot- - variant: slim- bake_target: runtime-slim- - variant: slim-nonroot- bake_target: runtime-slim-nonroot- - variant: code-slim- bake_target: runtime-code-slim- - variant: code-slim-nonroot- bake_target: runtime-code-slim-nonroot-- steps:- - uses: actions/checkout@v6-- - name: Determine image version- id: version- env:- MANUAL_VERSION: ${{ inputs.version || github.event.inputs.version }}- RELEASE_TAG: ${{ github.event.release.tag_name }}- run: |- version="${MANUAL_VERSION#v}"- if [ -z "$version" ] && [ -n "$RELEASE_TAG" ]; then- version="${RELEASE_TAG#v}"- fi- printf 'version=%s\n' "$version" >> "$GITHUB_OUTPUT"-- - name: Set up Python- if: steps.version.outputs.version != ''- uses: actions/setup-python@v5- with:- python-version: "3.12"-- - name: Sync versioned files for image build- if: steps.version.outputs.version != ''- run: |- python scripts/version-sync.py --version ${{ steps.version.outputs.version }}-- - name: Set up QEMU- uses: docker/setup-qemu-action@v4-- - name: Set up Docker Buildx- uses: docker/setup-buildx-action@v4-- - name: Log in to GHCR- uses: docker/login-action@v4- with:- registry: ${{ env.REGISTRY }}- username: ${{ github.actor }}- password: ${{ secrets.GITHUB_TOKEN }}-- - name: Extract metadata (variant)- id: meta- uses: docker/metadata-action@v6- with:- images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}- tags: |- type=ref,event=branch,enable=${{ inputs.enable_ref_tags }},suffix=${{ matrix.variant != '' && format('-{0}', matrix.variant) || '' }}- type=ref,event=pr,enable=${{ inputs.enable_ref_tags }},suffix=${{ matrix.variant != '' && format('-{0}', matrix.variant) || '' }}- type=raw,value=${{ steps.version.outputs.version }},enable=${{ steps.version.outputs.version != '' }},suffix=${{ matrix.variant != '' && format('-{0}', matrix.variant) || '' }}- type=semver,pattern={{version}},suffix=${{ matrix.variant != '' && format('-{0}', matrix.variant) || '' }}- type=semver,pattern={{major}}.{{minor}},suffix=${{ matrix.variant != '' && format('-{0}', matrix.variant) || '' }}- type=semver,pattern={{major}},suffix=${{ matrix.variant != '' && format('-{0}', matrix.variant) || '' }}- type=sha,prefix=${{ matrix.variant != '' && format('{0}-', matrix.variant) || 'sha-' }}- type=raw,value=${{ matrix.variant }},enable=${{ matrix.variant != '' }}- type=raw,value=latest,enable=${{ matrix.variant == '' }}-- - name: Build and push variant (bake)- id: bake- uses: docker/bake-action@v7- with:- files: |- ./docker-bake.hcl- cwd://${{ steps.meta.outputs.bake-file-tags }}- cwd://${{ steps.meta.outputs.bake-file-labels }}- targets: ${{ matrix.bake_target }}- push: true- set: |- *.cache-from=type=gha- *.cache-to=type=gha,mode=max-- - name: Install cosign- uses: sigstore/cosign-installer@v3-- - name: Sign images with cosign (keyless via Sigstore OIDC)- env:- BAKE_META: ${{ steps.bake.outputs.metadata }}- run: |- # Extract all pushed image digests from bake metadata and sign each- echo "$BAKE_META" | jq -r '- to_entries[].value."containerimage.digest" // empty- ' | while read -r digest; do- image="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${digest}"- echo "Signing ${image}"- cosign sign --yes "${image}"- done+name: Docker++on:+ workflow_call:+ inputs:+ version:+ description: "Version to stamp into the image contents and exact image tag"+ required: false+ type: string+ enable_ref_tags:+ description: "Whether to emit branch/PR ref tags"+ required: false+ default: true+ type: boolean+ workflow_dispatch:+ inputs:+ version:+ description: "Version to stamp into the image contents and exact image tag"+ required: false+ release:+ types: [published]++env:+ REGISTRY: ghcr.io++permissions:+ contents: read+ packages: write+ id-token: write # For cosign keyless signing via Sigstore OIDC++jobs:+ docker-variant-tags:+ runs-on: ubuntu-latest+ strategy:+ fail-fast: false+ matrix:+ include:+ - variant: ""+ bake_target: runtime+ - variant: nonroot+ bake_target: runtime-nonroot+ - variant: code+ bake_target: runtime-code+ - variant: code-nonroot+ bake_target: runtime-code-nonroot+ - variant: slim+ bake_target: runtime-slim+ - variant: slim-nonroot+ bake_target: runtime-slim-nonroot+ - variant: code-slim+ bake_target: runtime-code-slim+ - variant: code-slim-nonroot+ bake_target: runtime-code-slim-nonroot++ steps:+ - uses: actions/checkout@v6++ - name: Normalize image name+ id: image-name+ run: |+ image_name="$(printf '%s' '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')"+ printf 'image_name=%s\n' "$image_name" >> "$GITHUB_OUTPUT"++ - name: Determine image version+ id: version+ env:+ MANUAL_VERSION: ${{ inputs.version || github.event.inputs.version }}+ RELEASE_TAG: ${{ github.event.release.tag_name }}+ run: |+ version="${MANUAL_VERSION#v}"+ if [ -z "$version" ] && [ -n "$RELEASE_TAG" ]; then+ version="${RELEASE_TAG#v}"+ fi+ printf 'version=%s\n' "$version" >> "$GITHUB_OUTPUT"++ - name: Set up Python+ if: steps.version.outputs.version != ''+ uses: actions/setup-python@v5+ with:+ python-version: "3.12"++ - name: Sync versioned files for image build+ if: steps.version.outputs.version != ''+ run: |+ python scripts/version-sync.py --version ${{ steps.version.outputs.version }}++ - name: Set up QEMU+ uses: docker/setup-qemu-action@v4++ - name: Set up Docker Buildx+ uses: docker/setup-buildx-action@v4++ - name: Log in to GHCR+ uses: docker/login-action@v4+ with:+ registry: ${{ env.REGISTRY }}+ username: ${{ github.actor }}+ password: ${{ secrets.GITHUB_TOKEN }}++ - name: Extract metadata (variant)+ id: meta+ uses: docker/metadata-action@v6+ with:+ images: ${{ env.REGISTRY }}/${{ steps.image-name.outputs.image_name }}+ tags: |+ type=ref,event=branch,enable=${{ inputs.enable_ref_tags }},suffix=${{ matrix.variant != '' && format('-{0}', matrix.variant) || '' }}+ type=ref,event=pr,enable=${{ inputs.enable_ref_tags }},suffix=${{ matrix.variant != '' && format('-{0}', matrix.variant) || '' }}+ type=raw,value=${{ steps.version.outputs.version }},enable=${{ steps.version.outputs.version != '' }},suffix=${{ matrix.variant != '' && format('-{0}', matrix.variant) || '' }}+ type=semver,pattern={{version}},suffix=${{ matrix.variant != '' && format('-{0}', matrix.variant) || '' }}+ type=semver,pattern={{major}}.{{minor}},suffix=${{ matrix.variant != '' && format('-{0}', matrix.variant) || '' }}+ type=semver,pattern={{major}},suffix=${{ matrix.variant != '' && format('-{0}', matrix.variant) || '' }}+ type=sha,prefix=${{ matrix.variant != '' && format('{0}-', matrix.variant) || 'sha-' }}+ type=raw,value=${{ matrix.variant }},enable=${{ matrix.variant != '' }}+ type=raw,value=latest,enable=${{ matrix.variant == '' }}++ - name: Build and push variant (bake)+ id: bake+ uses: docker/bake-action@v7+ with:+ files: |+ ./docker-bake.hcl+ cwd://${{ steps.meta.outputs.bake-file-tags }}+ cwd://${{ steps.meta.outputs.bake-file-labels }}+ targets: ${{ matrix.bake_target }}+ push: true+ set: |+ *.cache-from=type=gha+ *.cache-to=type=gha,mode=max++ - name: Install cosign+ uses: sigstore/cosign-installer@v3++ - name: Sign images with cosign (keyless via Sigstore OIDC)+ env:+ BAKE_META: ${{ steps.bake.outputs.metadata }}+ run: |+ # Extract all pushed image digests from bake metadata and sign each+ echo "$BAKE_META" | jq -r '+ to_entries[].value."containerimage.digest" // empty+ ' | while read -r digest; do+ image="${{ env.REGISTRY }}/${{ steps.image-name.outputs.image_name }}@${digest}"+ echo "Signing ${image}"+ cosign sign --yes "${image}"+ donediff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex ff5f60a64..a08f05f2d 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -243,11 +243,20 @@ jobs:needs: [detect-version, build]if: github.event.inputs.dry_run != 'true' && vars.GH_PACKAGES_SKIP != 'true'runs-on: ubuntu-latest+ permissions:+ contents: read+ packages: writesteps:- uses: actions/checkout@v4with:fetch-depth: 0+ - name: Compute GitHub Packages scope+ id: gh-scope+ run: |+ scope="$(printf '%s' '${{ github.repository_owner }}' | tr '[:upper:]' '[:lower:]')"+ printf 'scope=%s\n' "$scope" >> "$GITHUB_OUTPUT"+- name: Set up Node.js for GitHub Package Registryuses: actions/setup-node@v4with:@@ -260,22 +269,79 @@ jobs:name: distpath: dist/+ - name: Publish ${{ env.NPM_SDK_PACKAGE }} to GitHub Package Registry+ id: gpr-sdk-publish+ env:+ NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}+ GITHUB_PACKAGES_SCOPE: ${{ steps.gh-scope.outputs.scope }}+ run: |+ workdir="$(mktemp -d)"+ assets_dir="$workdir/release-assets"+ mkdir -p "$assets_dir"++ cp -R sdk/typescript "$workdir/sdk"+ cd "$workdir/sdk"+ npm install+ npm run build+ npm version ${{ needs.detect-version.outputs.npm_version }} --no-git-tag-version --allow-same-version+ node <<'EOF'+ const fs = require("fs");+ const pkg = JSON.parse(fs.readFileSync("package.json", "utf8"));+ pkg.name = `@${process.env.GITHUB_PACKAGES_SCOPE}/${pkg.name}`;+ pkg.publishConfig = {+ ...(pkg.publishConfig || {}),+ registry: process.env.GITHUB_PACKAGES_REGISTRY_URL,+ };+ fs.writeFileSync("package.json", `${JSON.stringify(pkg, null, 2)}\n`);+ EOF+ sdk_tarball="$(npm pack --pack-destination "$assets_dir" | tail -n 1)"+ npm publish --access public --registry ${{ env.GITHUB_PACKAGES_REGISTRY_URL }}++ printf 'sdk_tarball=%s\n' "$assets_dir/$sdk_tarball" >> "$GITHUB_OUTPUT"+ continue-on-error: true+- name: Publish ${{ env.NPM_OPENCLAW_PACKAGE }} to GitHub Package Registry- id: gpr-publish+ id: gpr-openclaw-publishenv:NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}+ GITHUB_PACKAGES_SCOPE: ${{ steps.gh-scope.outputs.scope }}+ SDK_TARBALL: ${{ steps.gpr-sdk-publish.outputs.sdk_tarball }}run: |- cd plugins/openclaw+ workdir="$(mktemp -d)"+ cp -R plugins/openclaw "$workdir/openclaw"+ cd "$workdir/openclaw"+ node <<'EOF'+ const fs = require("fs");+ const pkg = JSON.parse(fs.readFileSync("package.json", "utf8"));+ pkg.dependencies = pkg.dependencies || {};+ delete pkg.dependencies["headroom-ai"];+ fs.writeFileSync("package.json", `${JSON.stringify(pkg, null, 2)}\n`);+ EOFnpm install+ npm install --no-save "$SDK_TARBALL"npm run buildnpm version ${{ needs.detect-version.outputs.npm_version }} --no-git-tag-version --allow-same-version+ node <<'EOF'+ const fs = require("fs");+ const pkg = JSON.parse(fs.readFileSync("package.json", "utf8"));+ const scopedSdk = `@${process.env.GITHUB_PACKAGES_SCOPE}/headroom-ai`;+ pkg.name = `@${process.env.GITHUB_PACKAGES_SCOPE}/${pkg.name}`;+ pkg.dependencies = pkg.dependencies || {};+ delete pkg.dependencies["headroom-ai"];+ pkg.dependencies[scopedSdk] = `^${pkg.version}`;+ pkg.publishConfig = {+ ...(pkg.publishConfig || {}),+ registry: process.env.GITHUB_PACKAGES_REGISTRY_URL,+ };+ fs.writeFileSync("package.json", `${JSON.stringify(pkg, null, 2)}\n`);+ EOFnpm publish --access public --registry ${{ env.GITHUB_PACKAGES_REGISTRY_URL }}continue-on-error: true- name: GPR publish notice- if: steps.gpr-publish.outcome == 'failure'+ if: steps.gpr-sdk-publish.outcome == 'failure' || steps.gpr-openclaw-publish.outcome == 'failure'run: |- echo "::notice::GitHub Package Registry publish failed. Check GITHUB_TOKEN permissions and registry configuration. Set GH_PACKAGES_SKIP=true to skip."+ echo "::notice::One or more GitHub Package Registry publishes failed. Check GITHUB_TOKEN permissions and package scope/repository settings. Set GH_PACKAGES_SKIP=true to skip."publish-docker:needs: [detect-version]@@ -290,8 +356,14 @@ jobs:enable_ref_tags: falsecreate-release:- needs: [detect-version, build, publish-docker]- if: github.event.inputs.dry_run != 'true'+ needs: [detect-version, build, publish-pypi, publish-npm, publish-github-packages, publish-docker]+ if: >-+ ${{+ always() &&+ github.event.inputs.dry_run != 'true' &&+ needs.detect-version.result == 'success' &&+ needs.build.result == 'success'+ }}runs-on: ubuntu-latestpermissions:contents: writediff --git a/docs/content/docs/releases.mdx b/docs/content/docs/releases.mdxindex 409eba908..818087df4 100644--- a/docs/content/docs/releases.mdx+++ b/docs/content/docs/releases.mdx@@ -16,8 +16,11 @@ The release workflow also calls `.github/workflows/docker.yml` as a reusable wor| `headroom-ai` | Python | PyPI | `PYPI_PACKAGE` || `headroom-ai` | TypeScript SDK | npmjs.org | `NPM_SDK_PACKAGE` || `headroom-openclaw` | TypeScript plugin | npmjs.org | `NPM_OPENCLAW_PACKAGE` |-| `headroom-openclaw` | TypeScript plugin | GitHub Package Registry | — |-| `ghcr.io/chopratejas/headroom` | Docker image | GitHub Container Registry | — |+| `@{owner}/headroom-ai` | TypeScript SDK | GitHub Package Registry | — |+| `@{owner}/headroom-openclaw` | TypeScript plugin | GitHub Package Registry | — |+| `headroom-ai-{version}.tar.gz` / `headroom_ai-{version}-py3-none-any.whl` | Python release assets | GitHub Release (`{owner}/headroom`) | — |+| `headroom-ai-{version}.tgz` / `headroom-openclaw-{version}.tgz` | Node release assets | GitHub Release (`{owner}/headroom`) | — |+| `ghcr.io/{owner}/headroom` | Docker image | GitHub Container Registry | — |## Version Strategy@@ -94,13 +97,18 @@ Publishes both TypeScript packages to npmjs.org:- `plugins/openclaw/` as `headroom-openclaw`### publish-github-packages-Publishes `plugins/openclaw/` to GitHub Package Registry (`npm.pkg.github.com`).+Publishes both Node packages to GitHub Package Registry (`npm.pkg.github.com`) using the current repository owner as the npm scope:+- `sdk/typescript/` as `@{owner}/headroom-ai`+- `plugins/openclaw/` as `@{owner}/headroom-openclaw`++### GitHub release assets+Uploads the built Python distributions and both npm tarballs to the GitHub Release created in the current repository. This is what makes fork-owned main-branch builds downloadable for local validation even when consumers are not pulling from PyPI or npmjs.org.### publish-dockerCalls the reusable Docker workflow to publish GHCR images with the same semantic version and synced package metadata as the rest of the release.### create-release-Creates or updates the GitHub Release, uploads the built Python distributions and npm tarballs as release assets, and publishes the generated changelog as release notes.+Creates or updates the GitHub Release in the current repo, uploads the built Python distributions and npm tarballs as release assets, and publishes the generated changelog as release notes. The job still runs after the build succeeds even if one of the external registry publishes fails, so GitHub-hosted artifacts remain available on `main`.## Configuration