repomatic.github.dev_release module¶
Sync a rolling dev pre-release on GitHub.
Maintains a single draft pre-release that mirrors the unreleased
changelog section and always carries the latest successful dev binaries
and Python package. The dev tag (like v6.1.1.dev0) is force-updated
to point to the latest main commit, so tags do not proliferate.
When the current version’s dev release already exists, it is edited
(not deleted and recreated) so that previously uploaded assets, especially
compiled binaries, survive pushes that skip binary compilation (like
documentation-only changes). The upload_release_assets() function deletes
all existing assets before uploading new ones, preventing stale files from
accumulating when the naming scheme changes. Stale dev releases from previous
versions are always deleted.
Note
Dev releases are created as drafts so they remain mutable even
when GitHub’s immutable releases setting is enabled. Immutability
only blocks asset uploads on published releases: deletion still
works. But because the workflow needs to upload binaries after
creation, the release must stay as a draft throughout its lifetime
to allow asset uploads. See docs/workflows.md § Immutable releases.
- repomatic.github.dev_release.DEV_ASSET_PATTERNS = ('*.bin', '*.exe', '*.tar.gz', '*.whl')¶
Glob patterns for dev release assets.
Both halves are spelled as globs from the sets that define them:
BINARY_ASSET_SUFFIXESfor the compiled binaries, so a dev pre-release carries exactly the artifacts the release workflow downloads andscan-virustotalsubmits, andPYTHON_DIST_SUFFIXESfor what a dev pre-release adds on top. Derived rather than re-listed, because a dev release advertising a different set of assets than the real one is the bug this pairing exists to prevent.Note
Bare extensions (no
repomatic-prefix) keep patterns generic so downstream repositories can reuse the same logic regardless of their package name.
- repomatic.github.dev_release.RELEASE_LIST_LIMIT = 100¶
How many releases, newest first, are read to find the dev pre-releases.
gh release listreads 30 without a limit. A dev pre-release is created after the last final release, so it sits at the top of the list: the limit only has to reach past the drafts a repository keeps around.
- repomatic.github.dev_release.sync_dev_release(changelog_path, version, repository, dry_run=True, asset_dir=None)[source]¶
Create or update the dev pre-release on GitHub.
Reads the changelog, renders the release body for the given version via
build_expected_body(), then either edits the existing dev release or creates a new one. Stale dev releases from previous versions are always cleaned up.Existing releases are edited (not deleted and recreated) to preserve assets like compiled binaries from previous successful builds. When
asset_diris provided, existing assets are deleted and new ones uploaded viaupload_release_assets().Whether the release exists is read from the release list, never from a failed edit: a draft carries no tag, so GitHub accepts a second draft of the same name, and creating one after an edit that failed for a transient reason would duplicate the pre-release.
- Parameters:
changelog_path (
Path) – Path tochangelog.md.version (
str) – Current version string (like6.1.1.dev0).repository (
str) – GitHub repository inowner/nameform.dry_run (
bool) – IfTrue, report without making changes.asset_dir (
Path|None) – Directory containing assets to upload. IfNone, no asset upload is performed.
- Return type:
- Returns:
Trueif the release was synced (or would be in dry-run),Falseif the changelog section is empty.- Raises:
RuntimeError – When the releases cannot be listed, or when the existing dev release cannot be edited.
- repomatic.github.dev_release.upload_release_assets(tag, repository, asset_dir)[source]¶
Upload assets to a GitHub release.
Scans
asset_dirfor files matchingDEV_ASSET_PATTERNS. If no matching files are found, returns immediately without modifying the release: this preserves existing assets for documentation-only pushes. When files are found, all existing assets are deleted first to prevent stale files from accumulating when the naming scheme changes.
- repomatic.github.dev_release.cleanup_dev_releases(repository, *, keep_tag=None)[source]¶
Delete stale dev pre-releases from GitHub.
Lists all releases and deletes any whose tag ends with a
.devNsegment, exceptkeep_tagwhich is preserved so its assets (like compiled binaries) survive. This handles stale dev releases left behind after version bumps. Silently succeeds if no dev releases exist or if individual deletions fail.
- repomatic.github.dev_release.delete_release_by_tag(tag, repository)[source]¶
Delete a release and its tag from GitHub.
Silently succeeds if the release does not exist or cannot be deleted. The outcome is returned rather than announced: this helper deletes any release, so only the caller knows what kind of release it just removed and can name it accurately.