feat(release): ability to increment minor and major version - #60
Merged
Conversation
Two ways to raise a minor or a major version, for the two moments when
it actually becomes known:
* `alex pubspec version <patch|minor|major>` (alias `alex pub version`) —
during the work on a task. Only the version is changed, a build number
is kept as is, because usually it's already prepared for the next
build; pass `--build` (`-b`) to increment it too.
* `alex release start --increment=<part>` (`-i`) — at the release time.
The version of this release is incremented before the release is
started, keeping the build number, so the release branch, CHANGELOG.md,
the tag and build artifacts use the new value. After the release a
patch and a build number are incremented in develop, as always.
Increment itself is extracted in VersionIncrement, and the replacement of
the version in pubspec.yaml — in Spec.replaceVersion: it replaces only
the value of the top level `version` key, keeps a trailing comment of the
line and fails if there is no version definition, instead of the silent
no-op of the previous `replaceFirst("version: $value")`. It's called
through the FileSystem, so the demonstration mode doesn't write in the
real pubspec.yaml anymore.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
No changes in the behavior, only the formatting of the files which were not formatted before. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR implements issue #12 by adding the ability to increment minor and major versions (previously only patch was supported). It introduces two entry points: a new alex pubspec version <part> command for bumping the version during work on a task, and a --increment (-i) option on alex release start to raise the version of the release itself. The version write path was also refactored to go through the FileSystem abstraction, so --demo mode no longer mutates the real pubspec.yaml.
Changes:
- New
VersionIncrementenum (apply,byName) andSpec.replaceVersion/versionOrNullhelpers, with unit tests. - New
pubspec versionsubcommand (aliaspub version) with an optional--buildflag, plusrelease start --incrementsupport that increments before the release and keeps the build number. - Documentation updates (README, CHANGELOG) and a separate
dart formatpass across many files.
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| lib/src/version_increment.dart | New enum encapsulating patch/minor/major increment logic, build-number handling, and pre-release preservation |
| lib/src/pub_spec.dart | Adds versionOrNull and regex-based replaceVersion that targets only the top-level version and fails when absent |
| lib/commands/pubspec/version_command.dart | New command to increment the version in the current directory's pubspec |
| lib/commands/pubspec/pubspec_command.dart | Registers the new VersionCommand subcommand |
| lib/commands/release/start_release_command.dart | Adds --increment option, applies it before the release (rollback-safe), and routes version writes through FileSystem |
| test/src/version_increment_test.dart | Unit tests for byName and apply behaviors |
| test/src/pub_spec_test.dart | Unit tests for replaceVersion and versionOrNull |
| README.md | Documents the --increment option and the pubspec version command |
| CHANGELOG.md | Adds ## Next entries for both new features |
| lib/src/l10n/exporters/arb_exporter.dart, lib/src/custom_commands/, lib/runner/alex_command_runner.dart, lib/commands/custom/, lib/commands/code/generate_command.dart, lib/src/changelog/changelog.dart, test/src/run/cmd_test.dart, test/src/release/release_rollback_test.dart, test/src/changelog/changelog_test.dart | Formatting-only (dart format) changes, no behavior impact |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
# Conflicts: # CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #12.
Only a patch version could be incremented before. Now a minor or a major one can be raised too — in the two moments when it actually becomes known.
1. During the work on a task —
alex pubspec version <part>New command (alias
alex pub version), where<part>ispatch,minorormajor.Only the version is changed, a build number is kept as is, because usually it's already prepared for the next build. Pass
--build(-b) to increment the build number too.1.2.3+4becomesalex pubspec version minor1.3.0+4alex pubspec version major2.0.0+4alex pubspec version minor --build1.3.0+5The command changes
pubspec.yamlin the current directory and doesn't commit anything. Then the release is started as usual — nothing should be passed toalex release start, the current version is released.2. At the release time —
alex release start --increment=<part>(-i)The version of this release is incremented before the release is started, keeping the build number, so the release branch,
CHANGELOG.md, the tag and build artifacts all use the new value:-idevelopafter the release1.2.3+41.2.4+5patch1.2.4+41.2.5+5minor1.3.0+41.3.1+5major2.0.0+42.0.1+5Without the option nothing changes — the behavior is exactly as before. After the release a patch and a build number are incremented in
developas always, and the resulting version is printed when the release is completed.The version is written only after all the arguments are validated, so an invalid value can't break the process in the middle; the commit is made before the release branch is created, so it's reverted by the release rollback if the release fails.
Under the hood
VersionIncrement(lib/src/version_increment.dart) — the increment itself:apply(version, {incrementBuild = false}). A pre-release suffix is always kept as is.Spec.replaceVersion()— replaces only the value of the top levelversionkey, keeps a trailing comment of the line, doesn't touch aversion:of a dependency and fails if there is no version definition. The previousreplaceFirst("version: $value", ...)silently did nothing on any mismatch (an extra space, for example).FileSystem, so the demonstration mode (--demo) doesn't write in the realpubspec.yamlanymore.Tests
dart analyze— no issues,dart test— all tests pass (14 new ones:test/src/version_increment_test.dart,test/src/pub_spec_test.dart).Both commands were also checked manually on a temporary project: all the parts,
--build, thepubalias, an empty/unknown/duplicated argument, and a version line with a comment.Second commit
chore: format code with dart format— the repository contained files which were not formatted, and they are formatted in a separate commit, so the feature diff stays clean. No changes in the behavior.🤖 Generated with Claude Code