Release command and workflow automation
reflex-release is a changelog-led release system for one Python package or a monorepo. It turns release intent into checked changelog updates, then turns those updates into built and approved PyPI publications through repository-local GitHub Actions workflows. The package also keeps package discovery, version rules, dependency pins, and workflow files aligned with one repository configuration.
Release model
The release model treats a versioned CHANGELOG.md heading and its matching git tag as the two sides of release state. A version is due when the changelog names it and the tag does not exist; the tag is created only after a successful upload.
This order makes a failed release retryable. Engineers fix the cause on top of the changelog change and push again. A tag means that the package is already published, so the next run can skip work that is complete.
The main release paths are:
| Path | Starting point | Result |
|---|---|---|
| Final release | News fragments and a dispatch action | A release pull request updates the changelog. Merging it starts publication. |
| Prerelease | A dispatch action | An alpha changelog version is pushed to a prerelease branch and can publish without a release pull request. |
| Publication | An untagged changelog version on an allowed branch | The package is built, checked, approved, uploaded, tagged, and recorded as a GitHub release. |
| Internal package release | A push that changes an internal package | The package receives an automatic patch release without a changelog. |
The repository's broader release policy is described in Release engineering. Benchmark history and performance-run policy are described in Performance benchmarking.
Benchmark history integration
The benchmark workflows are separate from package publication, but they provide the history path used by release backfills. The daily suite measures broad metrics on a standard runner, while the macro suite measures timing and latency on a dedicated runner. A watchdog cancels macro runs that wait too long when runner capacity is exhausted, so a queued job does not hold later benchmark work indefinitely.
References: .github/…/benchmarks_daily.yml• L5-17 .github/…/benchmarks_daily.yml• L111-138 .github/…/macro_benchmarks.yml• L5-15 .github/…/macro_benchmarks.yml• L145-167 .github/…/macro_watchdog.yml• L5-9 .github/…/macro_watchdog.yml• L35-77
Command orchestration
The reflex-release command is the common interface for local use and workflow jobs. Workflow inputs arrive as environment variables, while the same commands accept flags for diagnosis or controlled manual runs. A command failure returns a non-zero result so the surrounding workflow stops before it can publish an unsafe state.
The commands form four related groups:
| Group | Commands | Responsibility |
|---|---|---|
| Setup | init, sync, create, packages | Establish release files, keep generated workflows current, create news fragments, and show releasable packages. |
| Planning | detect, plan, materialize, open-release-pr, push-prerelease | Find due or selected packages, calculate versions, write changelogs, update publishable dependency floors, and deliver the result to a branch or pull request. |
| Publication | prepare-publish, pin-lockstep, verify-dist, check-dev-pins, extract-notes, push-tag, create-release, post-release | Validate one package release, prepare and verify its artifacts, upload it through the workflow, then create or verify its tag, GitHub release, and optional follow-up dispatch. |
| Pull request checks | check-headings, changelog-check, sync --check | Prevent hand-written publish triggers, require release notes for affected source, and reject stale generated workflows. |
Planning passes structured release data between commands. Materialization reports which dependency files changed, so delivery commits the changelogs and the related pin changes together instead of allowing unrelated work in the release commit. Publication also reads back the GitHub release after creation. This proves that its tag, title, prerelease state, and checksum record match the version that was uploaded before a post-release workflow receives the tag.
Version action semantics
Release actions express the intent behind a version rather than accepting an arbitrary version override. New prerelease actions start an alpha train at a patch, minor, or major level. continued-prerelease advances an existing alpha train, while release-from-prerelease turns that train into its final version. Final patch, minor, major, and post-release actions cover normal maintenance releases.
The planner uses the newest changelog version as the baseline when one exists. It falls back to the newest package tag for a package with no materialized changelog. A package selected with no explicit package list is auto-selected from pending news fragments, except that a final release from a prerelease train selects packages whose changelogs end in an alpha.
References: packages/…/cli.py• L62-78 packages/…/cli.py• L314-401 packages/…/commands.py• L197-473 packages/…/commands.py• L984-1156 packages/…/versions.py• L12-105
Repository configuration
The [tool.reflex-release] table in the repository-root pyproject.toml defines the release shape. Shared Towncrier settings define where fragments and changelogs live and how release headings are written. The generated changelog template keeps those headings readable by the release detector and places issue links before a trailing fenced code block when needed. The release package supports the current Towncrier 26 line, so the changelog tool and the release command can advance together. This lets the same command set work for a root package, a monorepo, or a repository with both public and internal packages.
The configuration controls these broad concerns:
- Repository layout: the root package, the sub-package directory, and the source directories used for impact checks. Extra source directories can connect shipped files outside a package to that package's release checks.
- Release policy: the main, prerelease, hotfix, and release-branch naming rules plus the tag prefix and release timezone.
- Package roles: releasable packages, internal packages, changelog-exempt packages, and packages that never publish.
- Coordinated releases: lockstep groups that share a version and may publish some members last.
- Build selection: ordinary in-repository builds or a repository-owned custom build workflow with expected artifact patterns.
- Workflow behavior: the command used by generated workflows, pinned uv and Python versions, package input mode, self-review policy, latest-release marking, and an optional post-release workflow.
The release command requires Python 3.11 or newer. Generated workflows default to uv 0.13.6 and Python 3.14.10. These defaults reject the compromised eMudhra intermediate CA certificates, while a consuming repository can override or clear the pins.
The repository runs the release command with uv run --frozen --package reflex-release reflex-release. The command and its lockfile therefore stay tied to the checked-in workspace version of the release package, while generated workflows remain tied to that same release behavior. The release package itself uses a tag-derived version and fixed build requirements, which keeps the tool that drives publication reproducible when it is built from this workspace.
The loader validates names and relationships before a workflow can act. It also validates uv and Python pins before writing them into generated YAML. For example, a package cannot be both internal and never-published, a never-published package cannot join a lockstep group or custom build, and a custom build cannot target a generated workflow. Branch prefixes must also remain distinct from the main branch. These checks keep a valid configuration from silently producing a release path that cannot work.
Package identity and layout
The tool uses a package directory name as its internal package identity. The published distribution name still comes from that package's project metadata. This distinction matters when release selection, source paths, changelog paths, tags, and artifact metadata meet.
The root package uses repository-root paths. Sub-packages are discovered below the configured package directory when their directories contain a pyproject.toml. A missing package directory is treated as a single-package layout rather than as an error.
New repositories can start with uvx reflex-release init, while this repository invokes its workspace copy through the frozen lock. The root project exposes the release package as a workspace member, so local release commands and generated workflow behavior move together.
References: pyproject.toml• L393-424 pyproject.toml• L523-586 packages/…/pyproject.toml• L1-47 packages/…/README.md• L24-37 packages/…/config.py• L86-222 packages/…/config.py• L224-571 packages/…/config.py• L852-1026 packages/…/changelog.md• L1-104
Package discovery
Discovery connects repository changes to release work. The system finds packages from the configured layout, finds pending news fragments from Towncrier categories, and reads the newest parseable changelog heading to decide whether a package version is due.
Source impact and release impact are separate. A change under configured package source paths needs a news fragment, while a release commit that changes only a package changelog or news directory does not create a new fragment requirement. Internal and never-published packages are excluded from the public changelog path.
The changelog parser and the publish detector share the same heading rules. This prevents a heading that the release checks cannot read from becoming a silent, undetected publication request. Orphan fragments can be associated with the pull request that added them before Towncrier consumes them, which preserves release-note links without making contributors know the pull request number in advance.
The repository-wide build check uses one discovery step for both of its package sets. It builds the root package and each package under packages/, then selects the subset that can receive minimum-dependency checks. The check jobs use the wheels from the build jobs instead of rebuilding sibling packages, so package additions update both checks together.
Release selection
The dispatch form is generated from the current releasable package set. A lockstep group receives one selection entry because selecting one member must select the whole group. If the package count exceeds GitHub's input limit, the form uses a comma-separated package field instead of one checkbox per package.
Selection is narrowed by release state and dependency readiness. An explicit selection fails when it names an invalid package or an unreleasable dependency pin. An automatically selected package can be held back with a reason so other independent packages can proceed.
References: packages/…/discovery.py• L114-157 packages/…/discovery.py• L223-356 packages/…/config.py• L390-453 packages/…/scaffold.py• L197-303 packages/…/commands.py• L365-473 packages/…/dispatch_release.yml• L57-68
Dependency pin management
Dependency pin management keeps published metadata installable while packages move through a release. A development version is not a publishable PyPI target, so a published dependency cannot retain a lower bound on a *.dev version. A prerelease floor is acceptable for a prerelease release, but a final release must not force users onto an unpublished or prerelease dependency when a published final version can satisfy the requirement.
During planning, the system checks the published dependency fields of each selected package. During materialization, it lifts an unsafe lower bound to the earliest tagged version that satisfies the full requirement. It updates the package metadata and re-resolves uv.lock when the lock file actually changes. If no tagged version can satisfy the requirement, the package is held back rather than producing a changelog version that cannot publish.
The check covers runtime and optional published dependencies. It does not treat development-only dependency groups as package metadata. It also leaves a deliberate prerelease pin on an outside dependency alone because this repository has no tag record with which to choose a replacement; an outside *.dev pin still blocks publication because no downstream user can install it from PyPI.
The repository also applies a date floor to third-party dependency resolution while exempting internal release packages from that floor. This allows lockstep packages to resolve against their latest published versions during a release without weakening the freshness limit for external dependencies.
Repository-wide build validation uses the same dependency check after it builds one wheel for each discovered package. The workflow tests each checkable package against its declared minimum dependencies on Python 3.11 and 3.14. This makes sibling wheels available to the check without rebuilding them in every matrix job. A final gate combines the build and check results so branch protection can use one stable status.
Release validation also checks that declared minimum dependency versions remain workable. scripts/check_min_deps.py discovers checkable workspace packages, compares type-check results at the latest compatible versions and at the declared minimums, and fails only when the minimum set adds errors. For an unpublished sibling pinned to a *.dev version, it makes a temporary local wheel available so the minimum check can test the real release relationship without treating the unpublished version as a PyPI package. Its --check-dev-pins mode separately rejects development-release pins in metadata that is about to publish.
References: pyproject.toml• L523-581 packages/…/dist.py• L145-197 scripts/check_min_deps.py• L1-35 scripts/check_min_deps.py• L218-296 scripts/check_min_deps.py• L451-595 scripts/check_min_deps.py• L597-647 .github/…/build_packages.yml• L21-128
Lockstep release ordering
A lockstep group gives several packages one release version and one selection unit. Members with exact sibling pins are published last, after the other members have uploaded and been tagged. The build stage can then rewrite the publishing package's sibling requirements to the exact release version without committing that temporary build change.
Before the rewrite, the release checks that the requirement can accept the target version and that the requirement is unambiguous. If one member's changelog advances without the required partner, detection fails closed. This protects downstream installation from a package that names a sibling version that does not exist yet.
References: pyproject.toml• L417-422 packages/…/devpins.py• L1-23 packages/…/devpins.py• L135-188 packages/…/devpins.py• L254-378 packages/…/devpins.py• L604-685 packages/…/dist.py• L145-197 packages/…/commands.py• L172-194 packages/…/commands.py• L673-692
Workflow scaffolding
init brings a repository into the release model without replacing configuration that already exists. It adds the release and Towncrier tables when absent, points Towncrier at the shared changelog template, creates news directories for applicable packages, and writes the generated workflows. sync renders the same workflows again from the current configuration.
Generated files stay in the consuming repository instead of being called from a shared remote workflow. This keeps the trusted-publishing workflow reference local, keeps relative reusable-workflow calls pointed at the consumer repository, and keeps event triggers and dispatch inputs beside the jobs they control.
The generated files carry a marker and a refresh command. sync updates marked files, refuses to overwrite an unmarked file unless forced, removes an obsolete generated internal-package workflow, and can run in check-only mode. It also checks that custom build workflows exist and expose the inputs that publication passes to them. Pull request checks run that check-only mode, so a package or policy change that needs new workflow content fails before release time.
Generated workflow set
Every configured repository receives four core workflows. Repositories with internal packages receive one additional workflow. Their roles are:
| Workflow | Role |
|---|---|
| changelog.yml | Checks news fragments, changelog heading ownership, and workflow freshness on pull requests. |
| dispatch_release.yml | Plans and materializes a selected release, then opens a final-release pull request or pushes a prerelease branch. |
| release_from_changelog.yml | Detects untagged changelog versions on publishing branches and calls the publication workflow. |
| publish.yml | Publishes one package version through build, artifact review, human approval, upload, tag, and GitHub release stages. |
| auto_release_internal.yml | Detects changed internal packages on the main branch and sends them through publication without a changelog version. |
References: packages/…/scaffold.py• L50-105 packages/…/scaffold.py• L154-255 packages/…/scaffold.py• L680-840 packages/…/scaffold.py• L892-930 packages/…/scaffold.py• L950-1035 packages/…/changelog.md• L1-104
Release workflow stages
The generated workflows divide release work by responsibility. Dispatch creates the release state. Changelog detection decides what is due. Publication handles one package at a time and keeps the artifact-producing work separate from the job that holds the PyPI credential.
The end-to-end relationship is:
flowchart LR
F[News fragments or release action] --> D[Dispatch release]
D --> C[Changelog version]
D --> B[Prerelease branch]
C --> R[Release from changelog]
B --> R
R --> P[Prepare one package]
P --> A[Build and verify artifacts]
A --> H[Human approval in pypi environment]
H --> U[Upload to PyPI]
U --> T[Push tag and create GitHub release]
T --> X[Optional post-release workflow]
The publication workflow exposes a small contract to its callers: package and optional version inputs. It emits the package's target version, tag, build directory, prerelease status, and latest-release status for later stages. A direct dispatch and a caller workflow use the same path, so both receive the same validation and approval behavior.
Prerelease delivery
New and continued prerelease actions materialize alpha sections and push them to a date-based prerelease branch. A continued action must run on the existing prerelease branch. The dispatch workflow then starts the changelog release check explicitly because a push made with the GitHub token does not start an ordinary push-triggered workflow.
Prerelease trains can receive new work by merging the main branch into the prerelease branch and dispatching continued-prerelease there. Converting the train to a final release collapses its alpha sections into one final changelog section and uses a release pull request.
References: packages/…/dispatch_release.yml• L4-55 packages/…/dispatch_release.yml• L57-128 packages/…/commands.py• L476-540 packages/…/commands.py• L1092-1156 packages/…/versions.py• L63-91
Changelog publication
The changelog workflow runs on the main, prerelease, and hotfix publishing branches. It detects every newest changelog version that has no matching tag, then sends each package to the shared publication path. Packages that publish last wait until the earlier lockstep members have completed and been tagged.
The workflow reports the result of each release leg as one batch outcome. A skipped leg is healthy only when detection found no work for it. This makes a held-back or unexpectedly skipped package visible instead of allowing a partial release to look successful.
References: packages/…/release_from_changelog.yml• L4-39 packages/…/release_from_changelog.yml• L41-111 packages/…/release_from_changelog.yml• L113-166 packages/…/commands.py• L197-257
Publication stages
Publication follows a fixed sequence:
- Prepare validates the package, target version, branch, changelog source of truth, lockstep partners, and existing tag.
- Build creates artifacts in an unprivileged job. A repository-owned custom build workflow may replace the standard build for packages such as platform-specific wheels.
- Collect checks artifact names and versions, checks configured artifact patterns, runs optional repository checks, extracts release notes, and records checksums for the exact files to upload.
- Publish waits for required reviewers on the
pypienvironment. It holds the OIDC permission and uploads only the collected artifact. - Tag and release runs after upload success. It pushes the tag, creates and verifies the GitHub release, and optionally dispatches a repository-owned follow-up workflow on that tag.
No tag or GitHub release is created before the upload succeeds. A repeated run can recognize a completed publication and can recover a missing checksum asset. It does not accept an unrelated or incomplete GitHub release as valid.
References: packages/…/dist.py• L32-142 packages/…/publish.yml• L6-46 packages/…/publish.yml• L82-181 packages/…/publish.yml• L183-295 packages/…/publish.yml• L296-436 packages/…/commands.py• L541-711 packages/…/commands.py• L1319-1499
Change checklist
When these files or sections are changed, remember to consider these:
- Changes to package layout, package roles, lockstep groups, or dispatch input mode can change generated workflow inputs and trigger paths. Run
syncand commit its output. - Changes to
cli-command, uv, or Python pins affect every generated release job. Keep the command and generated workflows on the same tool version. - Changes to Towncrier heading format or supported Towncrier versions must still allow the release detector to read back the version. Run the workflow freshness check before merging.
- Changes to the shared changelog template must keep issue links and fenced examples in the intended order. They must also preserve the heading shape that release detection reads.
- Changes to published dependency requirements must pass the installability and minimum-version checks. A pin that resolves in the workspace can still fail the PyPI metadata gate or expose a type error at its declared floor.
- Changes to package discovery or the checkable-package rule must keep the build matrix and the minimum-dependency matrix based on the same package set. The shared discovery step and its final gate must continue to cover both matrices.
- Changes to custom build workflow names, inputs, or artifact patterns must preserve the caller contract and the artifact set expected by publication.
- Changes to post-release workflow names or inputs must preserve the
tag,package, andversiondispatch contract and must keep the workflow on the default branch. - Changes to publication permissions or the
pypienvironment must preserve the reviewer gate and the separation between artifact creation and upload. - Changes to release branch triggers or batch reporting must preserve the explicit dispatch used for branches pushed with
GITHUB_TOKENand the failure signal for partial releases.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A changelog version heading is added by hand | The heading can trigger publication without the normal release plan | Pull request checks reject new headings unless the approved release path or edit label applies. |
| A release branch has an incomplete lockstep group | One package could publish with an unavailable exact sibling version | Detection stops the batch until all required members are due at the same version or already tagged. |
A published dependency retains a *.dev floor | Downstream users cannot install the released metadata from PyPI | Planning and materialization lift the floor to a satisfying tagged version or hold the package back. |
| A lockstep requirement cannot accept the target version or appears more than once | The publish-last artifact may carry the wrong sibling relationship | Planning checks the requirement before materialization, and the build check validates the temporary exact pin. |
| Declared minimum dependency versions are older than the APIs used by the package | The package may install but fail type checks for users at the supported lower bound | build_packages.yml builds workspace wheels once, then check_min_deps.py compares minimum and latest-compatible environments on Python 3.11 and 3.14. |
| The package build set and checkable package set drift apart | A package can build without its dependency floor being checked, or a check can lack its sibling wheel | The discover job produces both sets and the final gate combines all matrix results. |
| A custom build workflow is missing an input or expected artifact | GitHub cannot call the build or publication receives an incomplete set | Configuration sync checks the workflow contract, and artifact verification checks every declared name, version, and pattern. |
The pypi environment has no required reviewers | Upload could run without human approval | The publish stage checks the environment and fails closed. |
| An existing GitHub release has the wrong tag, title, state, prerelease flag, or checksum record | A retry could hand an unrelated release to downstream work | Release creation reads the record back and accepts an existing release only when its metadata matches. |
| Configuration changes without regenerated workflows | The checked-in workflow can use stale package inputs or policy | changelog.yml runs sync --check on pull requests. |
| A push-created prerelease branch does not start the changelog workflow | The alpha changelog remains unpublished | Dispatch explicitly runs release_from_changelog.yml on the pushed branch. |
| The shared changelog template places issue links after a trailing fenced block | Release notes can render with links in the wrong location | The template separates prose from a final fenced block before it adds issue links. |
Key files
| File | Why to read it |
|---|---|
| pyproject.toml | Defines the repository's release command, package roles, lockstep relationship, Towncrier layout, and dependency resolution policy. |
| packages/…/pyproject.toml | Defines the release command package's Python support, tag-derived version, and fixed build requirements. |
| packages/…/CHANGELOG.md | Records changes to the release package, including its supported Towncrier line and release behavior. |
| packages/…/README.md | Explains the release contract, repository setup, dependency pin rules, and generated workflow contracts for adopters. |
| packages/…/cli.py | Defines the command surface and how workflow environment values become command inputs. |
| packages/…/commands.py | Shows the high-level release sequence from planning through delivery, artifact checks, and publication records. |
| packages/…/config.py | Defines the repository release contract and validates package, branch, lockstep, custom-build, toolchain-pin, and workflow relationships. |
| packages/…/discovery.py | Explains package, news fragment, changelog, and source-impact discovery. |
| packages/…/devpins.py | Defines the installability gate and automatic dependency-floor updates. |
| packages/…/dist.py | Defines artifact identity checks and temporary exact pins for lockstep publication. |
| scripts/check_min_deps.py | Shows the minimum-version compatibility check and the publication gate for development-release pins. |
| .github/…/build_packages.yml | Shows the shared package discovery step, wheel build matrix, minimum-dependency matrix, Python support range, and stable branch gate. |
| packages/…/scaffold.py | Explains generated workflow ownership, dispatch input generation, custom build contracts, and drift checks. |
| packages/…/changelog.md | Defines the shared changelog output used by Towncrier, including release headings and issue-link placement around fenced examples. |
| packages/…/dispatch_release.yml | Shows how release actions become changelog materialization and prerelease or final delivery. |
| packages/…/release_from_changelog.yml | Shows how untagged changelog versions become publication calls and how batch failures are reported. |
| packages/…/publish.yml | Shows the artifact, approval, upload, tag, GitHub release, and post-release lifecycle. |
| packages/…/changelog.yml | Shows the pull request guards that protect changelog ownership and generated workflow freshness. |