ci: publish commit-addressed alpha releases of the Python SDK - #2787
Open
miguelg719 wants to merge 1 commit into
Open
ci: publish commit-addressed alpha releases of the Python SDK#2787miguelg719 wants to merge 1 commit into
miguelg719 wants to merge 1 commit into
Conversation
|
Contributor
There was a problem hiding this comment.
No issues found across 5 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Architecture diagram
sequenceDiagram
participant GHA as GitHub Actions
participant GIT as Git
participant PNPM as pnpm
participant CS as changeset CLI
participant SCRIPT as scripts/release/python-alpha-version.ts
participant PYDIR as packages/sdk-python (pyproject.toml)
participant UPL as uv lock/build
participant PYPI as PyPI
Note over GHA,PYPI: Python SDK Alpha Release Flow (per push)
GHA->>GIT: checkout repo (fetch-depth: 0)
GIT-->>GHA: full history (for commit count)
GHA->>PNPM: pnpm install --frozen-lockfile
GHA->>CS: changeset version --snapshot
CS-->>GHA: snapshot versions written to package.json (e.g., 4.0.3-alpha-<sha>)
GHA->>SCRIPT: pnpm exec tsx python-alpha-version.ts --check
SCRIPT->>PYDIR: read package.json version
alt snapshot present (should-publish=true)
SCRIPT->>SCRIPT: compute commit count via git rev-list --count HEAD
SCRIPT->>SCRIPT: pythonAlphaVersion(snapshot, count) → "4.0.3a0.dev1451"
SCRIPT-->>GHA: should-publish=true, version=4.0.3a0.dev<N>
GHA->>PNPM: just _version-python-alpha
PNPM->>CS: changeset version --snapshot (re-run)
PNPM->>SCRIPT: pnpm exec tsx python-alpha-version.ts
SCRIPT->>PYDIR: read pyproject.toml
SCRIPT->>PYDIR: write updated pyproject.toml with alpha version
SCRIPT-->>PNPM: done
PNPM->>UPL: uv lock (update lockfile)
PNPM->>UPL: uv build
UPL-->>GHA: .whl + .tar.gz
GHA->>GHA: smoke test wheel/sdist
GHA->>PYPI: uv publish --trusted-publishing
PYPI-->>GHA: package published as stagehand-4.0.3a0.dev<N>.whl
GHA->>GIT: tag stagehand-python@4.0.3a0.dev<N>
else no snapshot (should-publish=false)
SCRIPT-->>GHA: should-publish=false
Note over GHA: skip alpha publishing
end
Note over PYPI: Available via `pip install --pre stagehand`
Note over PYPI: Sorts below stable 4.0.3, above 4.0.2
miguelg719
force-pushed
the
miguelgonzalez/ap-2885-python-alpha-releases
branch
from
August 20, 2026 19:56
0de156e to
fac3850
Compare
miguelg719
changed the base branch from
miguelgonzalez/ap-2885-sdk-alpha-releases-fix
to
main
August 20, 2026 20:05
miguelg719
force-pushed
the
miguelgonzalez/ap-2885-python-alpha-releases
branch
from
August 20, 2026 20:09
fac3850 to
7412a3e
Compare
PyPI rejects local versions and PEP 440 cannot carry a commit sha, so the idiomatic analogue of npm's <next>-alpha-<sha> is the developmental release <next>a0.dev<N>. N is the commit count on main, which keeps builds ordered and makes re-runs idempotent; the stagehand-python@<version> tag maps a build back to its commit. Adds python-alpha-version.ts (derives the version from the changesets snapshot), a _version-python-alpha just recipe, an alpha input on the reusable publish-python workflow, and status + publish jobs in release.yml mirroring the stable Python release.
miguelg719
force-pushed
the
miguelgonzalez/ap-2885-python-alpha-releases
branch
from
August 20, 2026 20:12
7412a3e to
8c2e573
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
#2786 restores
<next>-alpha-<sha>npm releases on every push. This gives the Python SDK the equivalent channel.PyPI rejects local versions (
+<sha>) and PEP 440 only allows digits in a.devNsegment, so the commit can't be carried in the version. The idiomatic analogue is a developmental pre-release:4.0.3a0.dev<N>.a0marks the alpha channel — sorts below the4.0.3it precedes and is hidden frompip install stagehandunless--preis passed (same role as npm'salphadist-tag).N= commit count onmain, so successive pushes order correctly and re-running the workflow on the same commit is idempotent (PyPI rejects the duplicate rather than minting a second build).stagehand-python@<version>git tag maps a build back to its commit.What
scripts/release/python-alpha-version.ts(+ tests) — afterchangeset version --snapshot, reads the Python proxypackage.json; if it got a snapshot version there's something unreleased, so rewritepyproject.tomlto<base>a0.dev<N>. Otherwiseshould-publish=false.--checkmode doesn't write.justfile—_version-python-alpha:changeset version --snapshot→ apply alpha version →uv lock.publish-python.yml— newalphaboolean input; when set, runsjust _version-python-alphabetweenjust installandjust build. Everything downstream (version read, wheel/sdist smoke tests,uv publish --trusted-publishing, git tag) is unchanged and reused. Checkout is nowfetch-depth: 0for the commit count.release.yml—python-alpha-status+publish-python-alphajobs, mirroring the stablepython-release-status+publish-pythonpair.Verified locally
With a throwaway changeset: snapshot →
should-publish=true version=4.0.3a0.dev1451,uv lockupdates cleanly,uv buildproducesstagehand-4.0.3a0.dev1451-py3-none-any.whl+ sdist, andpackagingconfirms4.0.2 < 4.0.3a0.dev1451 < 4.0.3withis_prerelease=True.pnpm exec vitest run scripts→ 66/66.Things to be aware of
pypienvironment, both reused here, so no PyPI config change is needed. If thepypienvironment has required reviewers, every alpha will wait for approval — worth checking before merge.Summary by cubic
Publishes commit-addressed Python SDK alphas as PEP 440 developmental releases. Previously we only shipped stable versions; CI now publishes
<next>a0.dev<N>when a changesets snapshot exists, ordered by commit count and requiring--preto installstagehand(AP-2885).Adds
scripts/release/python-alpha-version.ts(+ tests) to map snapshot versions (<next>-alpha-<sha>) to PEP 440, rewritepyproject.toml, and support--check; outputsshould-publishandversion.Extends reusable
publish-python.ymlwith analphainput; applies the version viajust _version-python-alpha, checks out withfetch-depth: 0, and reuses trusted publishing.Adds
python-alpha-statusandpublish-python-alphajobs inrelease.ymlto gate alpha publishing on snapshot presence and reuse the publish workflow.Rollout: Reuses the existing
pypienvironment and trusted publishing; required reviewers will gate each alpha. Install withpip install --pre stagehand; dev builds will accumulate on PyPI.Written for commit 8c2e573. Summary will update on new commits.