Skip to content

Merge pull request #34 from 0xPlaygrounds/hermes-readme #5

Merge pull request #34 from 0xPlaygrounds/hermes-readme

Merge pull request #34 from 0xPlaygrounds/hermes-readme #5

name: Publish Hermes Python Plugin
on:
workflow_dispatch:
push:
branches:
- main
permissions:
contents: read
id-token: write
concurrency:
group: publish-hermes-python-${{ github.ref }}
cancel-in-progress: true
jobs:
publish:
name: Build and publish Hermes Python plugin
runs-on: ubuntu-latest
# Auto-publish only on the "Version Packages" commit created by
# changesets/action when that PR merges — same gate publish.yml uses
# (inverted) for dev snapshots. Manual dispatch is always allowed.
if: >-
github.event_name == 'workflow_dispatch' ||
startsWith(github.event.head_commit.message, 'Version Packages')
steps:
- name: Check out repository
uses: actions/checkout@v4
# Fail fast with a clear message if the version in pyproject.toml has
# already been uploaded to PyPI. PyPI rejects file-name reuse with a
# 400 buried at the tail of a long log; surface the mistake up front so
# the fix (bump the version via changeset, merge, re-dispatch) is obvious.
- name: Preflight — check PyPI version availability
run: |
set -euo pipefail
version=$(grep -E '^version = "[^"]+"' packages/hermes-ryzome/pyproject.toml | head -1 | sed -E 's/version = "([^"]+)"/\1/')
if [ -z "$version" ]; then
echo "::error::Could not read version from packages/hermes-ryzome/pyproject.toml"
exit 1
fi
echo "Checking hermes-ryzome-plugin==$version against PyPI"
status=$(curl -s -o /dev/null -w '%{http_code}' "https://pypi.org/pypi/hermes-ryzome-plugin/$version/json")
if [ "$status" = "200" ]; then
echo "::error::hermes-ryzome-plugin $version is already on PyPI. Bump the version via 'pnpm changeset', merge the Version Packages PR, then re-run this workflow."
exit 1
fi
if [ "$status" != "404" ]; then
echo "::warning::Unexpected PyPI response $status while checking version availability — continuing."
fi
echo "Version $version not yet on PyPI; proceeding."
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10.31.0
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "24"
cache: "pnpm"
- name: Enable Corepack
run: corepack enable
- name: Install dependencies
run: pnpm install --frozen-lockfile
# Regenerates ryzome_hermes_plugin/tool_manifest.json from toolRegistry so the
# shipped Python sdist/wheel carries schemas matching the current code.
- name: Build Hermes plugin (regenerate tool manifest)
run: pnpm --filter @ryzome-ai/hermes-ryzome... build
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install build backend
run: python -m pip install --upgrade build
- name: Build Python distribution
run: python -m build packages/hermes-ryzome --outdir dist/hermes-python
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/hermes-python