quality, 7 findings: _release_impl and release take one frozen ReleaseOptions (new options.py, exported from pkgmgr.actions.release) and split into small private helpers with a frozen _Prepared carrier; the three _release_impl call paths become one plus dataclasses.replace(preview=True) for the interactive preview. cli/commands/release.py and cli/parser/release_cmd.py split into helpers with arguments in the same order, so the CLI surface is unchanged; test_workflow.py uses one with-block instead of five patch decorators. CodeRabbit: with --expect-tree an existing but untracked release input (pyproject, CHANGELOG.md, flake.nix, PKGBUILD, spec, debian/changelog, Cargo files) aborts before any write; the README says the abort comes before any release file is written and the pull is not reverted. | 🌿 Branch | 📊 Diff stat | 🎯 Fix | 💥 Break | 💸 Tokens | ⏱️ Velocity | 🛡️ Security | 🏆 Score | Gate | | --- | --- | --- | --- | --- | --- | --- | --- | --- | | feature/release-expect-tree | 13 files +457/-342 | 91 % | 4 % | – | – | 100 % | 87 | ✅ 90/5, tokens and velocity <= 100, security 100 % | Evidence: tests/unit + tests/integration with PYTHONPATH=src 886 passed; 2 known gpg-in-sandbox failures in test_publish_integration. quality check --staged 0 findings, ruff clean, MEDUSA 100 %, critical 0. Hub review e12f7e62ce35b6f5. Refs https://github.com/kevinveenbirkenbach/package-manager/pull/19 Created-with: https://s.veen.world/skills Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
5.5 KiB
Release Action
This module implements the pkgmgr release workflow.
It provides a controlled, reproducible release process that:
- bumps the project version
- updates all supported packaging formats
- creates and pushes Git tags
- optionally maintains a floating
latesttag - optionally closes the current branch
The implementation is intentionally explicit and conservative to avoid accidental releases or broken Git states.
What the Release Command Does
A release performs the following high-level steps:
- Synchronize the current branch with its upstream (fast-forward only)
- Determine the next semantic version
- Update all versioned files
- Commit the release
- Create and push a version tag
- Optionally update and push the floating
latesttag - Optionally close the current branch
All steps support preview (dry-run) mode.
Supported Files Updated During a Release
If present, the following files are updated automatically:
pyproject.tomlCHANGELOG.mdflake.nixPKGBUILDpackage-manager.specdebian/changelog
Missing files are skipped gracefully.
Git Safety Rules
The release workflow enforces strict Git safety guarantees:
- A
git pull --ff-onlyis executed before any file modifications - No merge commits are ever created automatically
- Only the current branch and the newly created version tag are pushed
git push --tagsis intentionally not used- The floating
latesttag is force-pushed only when required
Semantic Versioning
The next version is calculated from existing Git tags:
- Tags must follow the format
vX.Y.Z - The release type controls the version bump:
patchminormajor
The new tag is always created as an annotated tag.
Floating latest Tag
The floating latest tag is handled explicitly:
latestis updated only if the new version is the highest existing version- Version comparison uses natural version sorting (
sort -V) latestalways points to the commit behind the version tag- Updating
latestuses a forced push by design
This guarantees that latest always represents the highest released version,
never an older release.
Preview Mode
Preview mode (--preview) performs a full dry-run:
- No files are modified
- No Git commands are executed
- All intended actions are printed
Example preview output includes:
- version bump
- file updates
- commit message
- tag creation
- branch and tag pushes
latestupdate (if applicable)
Interactive vs Forced Mode
Interactive (default)
- Run a preview
- Ask for confirmation
- Execute the real release
Forced (--force)
- Skips preview and confirmation
- Skips branch deletion prompts
- Executes the release immediately
Branch Closing (--close)
When --close is enabled:
mainandmasterare never deleted- Other branches:
- prompt for confirmation (
y/N) - can be skipped using
--force
- prompt for confirmation (
- Branch deletion happens only after a successful release
Audited Tree (--expect-tree <sha>)
Pins the release to an audited tree:
- After the pull (
fetch+pull --ff-only) and before any file is written,git rev-parse HEAD^{tree}must equal the given full sha - Any other tree, also one a push brought in after the audit, aborts the release with a non-zero exit before any release file is written; the pull already ran and is not reverted, so HEAD and tracked files may have moved
- A release input (pyproject, changelogs, flake, packaging or Cargo files) that exists but is untracked is not part of the audited tree, so it aborts the release the same way
- With
--retrythe check runs before anything is pushed
Execution Flow (ASCII Diagram)
+---------------------+
| pkgmgr release |
+----------+----------+
|
v
+---------------------+
| Detect branch |
+----------+----------+
|
v
+------------------------------+
| git fetch / pull --ff-only |
+----------+-------------------+
|
v
+------------------------------+
| Determine next version |
+----------+-------------------+
|
v
+------------------------------+
| Update versioned files |
+----------+-------------------+
|
v
+------------------------------+
| Commit release |
+----------+-------------------+
|
v
+------------------------------+
| Create version tag (vX.Y.Z) |
+----------+-------------------+
|
v
+------------------------------+
| Push branch + version tag |
+----------+-------------------+
|
v
+---------------------------------------+
| Is this the highest version? |
+----------+----------------------------+
|
yes | no
|
v
+------------------------------+ +----------------------+
| Update & push `latest` tag | | Skip `latest` update |
+----------+-------------------+ +----------------------+
|
v
+------------------------------+
| Close branch (optional) |
+------------------------------+
Design Goals
- Deterministic and reproducible releases
- No implicit Git side effects
- Explicit tag handling
- Safe defaults for interactive usage
- Automation-friendly forced mode
- Clear separation of concerns:
workflow.py– orchestrationgit_ops.py– Git operationsprompts.py– user interactionversioning.py– SemVer logic
Summary
pkgmgr release is a deliberately strict release mechanism.
It trades convenience for safety, traceability, and correctness — making it suitable for both interactive development workflows and fully automated CI/CD