Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

ci(hogli): publish to pypi via trusted publishing (#57207)

Raúl Negrón-Otero636f5805ef0c
diff --git a/.github/workflows/publish-hogli.yml b/.github/workflows/publish-hogli.yml
new file mode 100644
index 000000000000..6ff969cd41b8
--- /dev/null
+++ b/.github/workflows/publish-hogli.yml
@@ -0,0 +1,83 @@
+name: Publish hogli to PyPI
+
+on:
+ push:
+ tags:
+ - 'hogli-v*'
+ workflow_dispatch:
+
+permissions:
+ contents: read
+
+concurrency:
+ group: publish-hogli-${{ github.ref }}
+ cancel-in-progress: false
+
+jobs:
+ publish:
+ name: Build and publish
+ # Hard guard: only publish from a tag ref. workflow_dispatch is supported
+ # so a failed publish can be re-run against the existing tag (via
+ # `gh workflow run publish-hogli.yml --ref hogli-vX.Y.Z`); dispatching
+ # from a branch is a no-op.
+ if: startsWith(github.ref, 'refs/tags/hogli-v')
+ runs-on: ubuntu-22.04
+ timeout-minutes: 10
+ environment: pypi-hogli
+ permissions:
+ id-token: write
+ contents: write
+ attestations: write
+ steps:
+ - uses: actions/checkout@v6
+
+ - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
+ with:
+ python-version: '3.12'
+
+ - uses: astral-sh/setup-uv@eac588ad8def6316056a12d4907a9d4d84ff7a3b # v7.3.0
+ with:
+ version: '0.10.2'
+
+ - name: Verify tag matches package version
+ shell: bash
+ env:
+ TAG_REF: ${{ github.ref_name }}
+ run: |
+ tag_version="${TAG_REF#hogli-v}"
+ pkg_version=$(python -c "import tomllib; print(tomllib.load(open('tools/hogli/pyproject.toml','rb'))['project']['version'])")
+ if [[ "$tag_version" != "$pkg_version" ]]; then
+ echo "::error::tag version ($tag_version) does not match tools/hogli/pyproject.toml version ($pkg_version)"
+ exit 1
+ fi
+
+ - name: Build sdist and wheel
+ run: uv build tools/hogli --out-dir dist
+
+ - name: Validate metadata
+ run: uvx twine check dist/*
+
+ - name: Smoke-test built wheel
+ shell: bash
+ env:
+ TAG_REF: ${{ github.ref_name }}
+ run: |
+ tag_version="${TAG_REF#hogli-v}"
+ uv venv /tmp/hogli-smoke
+ uv pip install --python /tmp/hogli-smoke/bin/python --find-links dist "hogli==$tag_version"
+ /tmp/hogli-smoke/bin/hogli --help
+
+ - name: Generate build provenance attestation
+ uses: actions/attest-build-provenance@e8998f949152b193b063cb0ec769d69d929409be # v2.4.0
+ with:
+ subject-path: 'dist/*'
+
+ - name: Publish to PyPI
+ run: uv publish dist/*
+
+ - name: Create GitHub Release
+ uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v3.0.0
+ with:
+ files: dist/*
+ generate_release_notes: true
+ prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') || contains(github.ref, 'rc') }}
diff --git a/tools/hogli/LICENSE b/tools/hogli/LICENSE
new file mode 100644
index 000000000000..4267194a9f62
--- /dev/null
+++ b/tools/hogli/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2026 PostHog Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/tools/hogli/README.md b/tools/hogli/README.md
index 8e51775d6329..22317b4262e8 100644
--- a/tools/hogli/README.md
+++ b/tools/hogli/README.md
@@ -259,6 +259,35 @@ metadata:
- click
- pyyaml
+## Releasing
+
+Releases are published to PyPI via `.github/workflows/publish-hogli.yml`,
+triggered by pushing a `hogli-v*` tag from `master`.
+
+1. Bump `version` in `tools/hogli/pyproject.toml` and merge to `master`.
+2. From `master`, tag and push:
+
+ ```bash
+ git tag hogli-v0.1.1
+ git push origin hogli-v0.1.1
+ ```
+
+The workflow verifies the tag matches the `pyproject.toml` version, builds
+the sdist and wheel with `uv build`, smoke-tests the wheel in a fresh
+venv, publishes via PyPI trusted publishing (OIDC) — no API tokens —
+and creates a GitHub Release with auto-generated notes from the commits
+since the previous tag.
+
+To re-trigger after a failed publish, dispatch the workflow against the
+existing tag — no need to retag:
+
+```bash
+gh workflow run publish-hogli.yml --ref hogli-v0.1.1
+```
+
+The publish job is guarded by `if: startsWith(github.ref, 'refs/tags/hogli-v')`,
+so dispatches from a branch are no-ops.
+
## License
MIT