Skip to content

ci: publish to PyPI on version tags#348

Closed
KylinMountain wants to merge 1 commit into
mainfrom
ci/pypi-publish-main
Closed

ci: publish to PyPI on version tags#348
KylinMountain wants to merge 1 commit into
mainfrom
ci/pypi-publish-main

Conversation

@KylinMountain

@KylinMountain KylinMountain commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Adds a tag-triggered PyPI release workflow directly on main, so the stable branch owns the release infrastructure independently of dev.

What it does

Pushing a PEP 440 tag with a leading v (v0.3.0, v0.3.0rc1, v0.3.0.dev2, …) triggers .github/workflows/publish.yml, which:

  1. derives the version from the tag and injects it into pyproject.toml;
  2. builds sdist + wheel;
  3. publishes to PyPI via OIDC trusted publishing (no stored token/secret);
  4. creates a GitHub Release with auto-generated notes.

Scope

Single file: .github/workflows/publish.yml. No code changes.

Supersedes the dev-based #347 (same workflow, targeted at main instead).

Add .github/workflows/publish.yml: pushing a PEP 440 tag (v0.3.0, v0.3.0rc1,
v0.3.0.dev2, …) derives the version from the tag, injects it into
pyproject.toml, builds, publishes to PyPI via OIDC trusted publishing (no
stored token), and creates a GitHub Release with generated notes.

Mirrors the OpenKnowledgeBase publish flow; keeps poetry-core as the build
backend and injects the version in CI, so contributors' local builds are
unaffected. Action refs pinned to commit SHAs (Node 24 releases).

One-time setup: a PyPI Trusted Publisher on the pageindex project
(VectifyAI/PageIndex, workflow publish.yml, environment pypi) and a GitHub
Environment named pypi.

Claude-Session: https://claude.ai/code/session_01Kx5DgKbhK1N8autqXH8SmS
@rejojer

rejojer commented Jul 8, 2026

Copy link
Copy Markdown
Member

Code review

Found 1 issue:

  1. Workflow will always fail: pyproject.toml does not exist on main (bug: missing build dependency on target branch)

The workflow's build step assumes pyproject.toml exists at the repo root, but main has no pyproject.toml, setup.py, or setup.cfg — only a flat requirements.txt. The file only exists on dev. Under set -euo pipefail, sed -i will fail immediately with "No such file or directory" on every tag push, making the workflow completely non-functional.

This appears to have been copied from PR #347 (which correctly targets dev) without accounting for the packaging divergence between main and dev. To fix, either: (a) add pyproject.toml with a [build-system] table to main before or as part of this PR, (b) retarget this PR to dev, or (c) merge one of the pending packaging PRs (e.g. #211) to main first.

python -m pip install --upgrade build packaging
VERSION="${GITHUB_REF_NAME#v}"
echo "Publishing version: $VERSION"
# Fail early on a malformed tag instead of publishing a junk version.
python -c "from packaging.version import Version; Version('$VERSION')"
# The git tag is the single source of truth; overwrite the static
# placeholder in [tool.poetry] so the built artifacts carry $VERSION.
sed -i "s/^version = .*/version = \"$VERSION\"/" pyproject.toml
grep '^version = ' pyproject.toml
python -m build

🤖 Generated with Claude Code

- If this code review was useful, please react with 👍. Otherwise, react with 👎.

@KylinMountain

Copy link
Copy Markdown
Collaborator Author

closed as #347 has merged into dev.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants