repomatic.github.release_sync module¶
Sync GitHub release notes from changelog.md.
Compares each GitHub release body against the corresponding
changelog.md section and updates any that have drifted.
changelog.md is the single source of truth.
- repomatic.github.release_sync.build_expected_body(changelog, version, *, admonition_override=None)[source]¶
Build the expected release body from the changelog.
Decomposes the changelog section into discrete elements and renders them through the
github-releasestemplate. This allows the GitHub release body to include a different subset of elements than therelease-notestemplate used forchangelog.mdentries.Lives here, with the release publishers, rather than in
repomatic.changelog: every caller is a GitHub-release writer (this sync, the dev pre-release, the release-notes metadata keys), and the changelog module renders changelog entries, not release bodies. The release draft is one more: seebuild_draft_body().- Parameters:
changelog (
Changelog) – Parsed changelog instance.version (
str) – Version string, like1.2.3.admonition_override (
str|None) – If provided, replaces theavailability_admonitionfrom the changelog. Used bybuild_pypi_body()to inject a pre-computed admonition at release time.
- Return type:
- Returns:
The rendered release body, or empty string if the version has no changelog section.
- repomatic.github.release_sync.build_pypi_body(changelog, version, package_name)[source]¶
Build the release body of a version published on PyPI.
The body of
build_expected_body(), with the availability admonition linking to PyPI and GitHub injected beforefix-changelogwrites it intochangelog.md. The admonition comes fromavailability_admonition(), the rendererfix-changelogwrites the section with, so both word it the same way.The draft cannot ask the platforms which release came first: the PyPI upload runs beside it, and a failed lookup reads like an empty one. The changelog answers instead, as
lint-changelogwill once both platforms carry the release.
- repomatic.github.release_sync.build_draft_body(changelog, version, package_name)[source]¶
Build the body a release draft is created with.
The body carries the PyPI availability admonition from the start: baking it into the draft, rather than editing the release from the caller’s fast
publish-pypilane, avoids a race between the lanes. That edit can run before the draft exists. The bake is optimistic: it assumes the parallel PyPI upload succeeds, which it does on the normal path, and a failed upload surfaces as a redpublish-pypijob.- Parameters:
- Return type:
- Returns:
build_pypi_body()for a PyPI project, elsebuild_expected_body(). Empty when the changelog holds no section for version.
- class repomatic.github.release_sync.SyncRow(action, version, release_url)[source]¶
Bases:
objectPer-release detail for the markdown report table.
- action: ReportAction¶
- class repomatic.github.release_sync.SyncResult(dry_run=True, rows=list(), total=0, in_sync=0, drifted=0, updated=0, failed=0, missing_changelog=0)[source]¶
Bases:
objectAccumulated results from a release-notes sync run.
- repomatic.github.release_sync.sync_github_releases(repo_url, changelog_path, dry_run=True)[source]¶
Sync GitHub release bodies from
changelog.md.For each released version in the changelog, compares the expected body (from
changelog.md) with the actual GitHub release body. In live mode, updates drifted releases viagh release edit.Live mode reads the release bodies fresh rather than from the day-long cache: an edit decided against a stale body would rewrite a release that already matches, or miss one that drifted since.
- Parameters:
- Return type:
- Returns:
Structured sync results.
- repomatic.github.release_sync.render_sync_report(result)[source]¶
Render a markdown report from sync results.
- Parameters:
result (
SyncResult) – Structured results from the sync run.- Return type:
- Returns:
Markdown report string.