Replace mix tag with mix_version - #24
Conversation
Delegates version bumping and git tagging to mix_version. Extracts changelog finalization into Mix.Tasks.Changelog.Finalize. The mix tag alias now runs safety checks, then calls changelog.finalize and version in sequence before pushing atomically.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 77f5594d3d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| cond do | ||
| "--major" in args -> {:ok, :major} | ||
| "--minor" in args -> {:ok, :minor} | ||
| "--patch" in args -> {:ok, :patch} |
There was a problem hiding this comment.
Reject ambiguous bump args before changelog commit
parse_bump_flag/1 accepts any argv that merely contains one recognized bump flag and silently picks the first match, so inputs like mix tag --major --patch (or --patch plus an unsupported extra arg) still let changelog.finalize write and commit CHANGELOG.md. The next step in tag_release/1 (Mix.Task.run("version", args)) then uses mix_version’s stricter option parsing and can halt on invalid/mutually-exclusive flags, leaving a partial release state with a committed changelog but no version bump/tag. Validate that argv is exactly one allowed bump selector before committing.
Useful? React with 👍 / 👎.
Allow exactly one of --major, --minor, --patch. Multiple or unknown
flags now return {:error, :invalid_flag} before changelog is committed.
…plans/replace_tag_with_mix_version.md`
Summary
mix_version ~> 2.4dependency withversioningconfig inmix.exsmix taginto newMix.Tasks.Changelog.Finalizetask (mix changelog.finalize --patch/--minor/--major)mix tagwith atag_release/1alias that runs safety checks, then callschangelog.finalizeandversionin sequence, then pushes atomicallylib/mix/tasks/tag.exand its test file; replace withlib/mix/tasks/changelog/finalize.exandtest/mix/tasks/changelog/finalize_test.exsTest plan
parse_bump_flag/1,bump_version/2,unreleased_entries/1,finalize_changelog/3mix quality --quick)Implementation Plan
Replace DIY
mix tagwithmix_versionContext
The custom
Mix.Tasks.Taghandles version bumping, changelog finalization, and git operationsin ~320 lines.
mix_versionhandles version bump + commit + tag out of the box. By extractingchangelog management into its own task and delegating version work to
mix_version, we reducecustom code and align with community tooling.
Trade-off
This splits the single release commit into two: one for the changelog, one for the version bump.
The git history goes from:
to:
Steps
1. Add
mix_versiondependencyIn
mix.exsdeps:Add
:versioningtoproject/0:2. Create
lib/mix/tasks/changelog/finalize.exExtract from the existing
tag.ex:unreleased_entries/1-- validates [Unreleased] section has entriesfinalize_changelog/3-- moves entries under a versioned headingconfirm_release/3-- shows entries and prompts y/N3. Replace function alias in
mix.exsUpdate
aliases/0withtag_release/1that runs safety checks, thenchangelog.finalize,version, and pushes.4. Delete
lib/mix/tasks/tag.ex5. Move safety checks to
tag_release/16. Update tests
unreleased_entries/1andfinalize_changelog/3(move to new module)bump_version/2,update_version_in_mix/2,parse_component/1