Skip to content

feat(release): ability to increment minor and major version - #60

Merged
greymag merged 3 commits into
masterfrom
worktree-issue12
Aug 25, 2026
Merged

feat(release): ability to increment minor and major version#60
greymag merged 3 commits into
masterfrom
worktree-issue12

Conversation

@greymag

@greymag greymag commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

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> is patch, minor or major.

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.

Command 1.2.3+4 becomes
alex pubspec version minor 1.3.0+4
alex pubspec version major 2.0.0+4
alex pubspec version minor --build 1.3.0+5

The command changes pubspec.yaml in the current directory and doesn't commit anything. Then the release is started as usual — nothing should be passed to alex 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:

-i Released version Version in develop after the release
not set 1.2.3+4 1.2.4+5
patch 1.2.4+4 1.2.5+5
minor 1.3.0+4 1.3.1+5
major 2.0.0+4 2.0.1+5

Without the option nothing changes — the behavior is exactly as before. After the release a patch and a build number are incremented in develop as 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 level version key, keeps a trailing comment of the line, doesn't touch a version: of a dependency and fails if there is no version definition. The previous replaceFirst("version: $value", ...) silently did nothing on any mismatch (an extra space, for example).
  • Version is written through the FileSystem, so the demonstration mode (--demo) doesn't write in the real pubspec.yaml anymore.

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, the pub alias, 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

greymag and others added 2 commits August 25, 2026 11:08
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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 VersionIncrement enum (apply, byName) and Spec.replaceVersion/versionOrNull helpers, with unit tests.
  • New pubspec version subcommand (alias pub version) with an optional --build flag, plus release start --increment support that increments before the release and keeps the build number.
  • Documentation updates (README, CHANGELOG) and a separate dart format pass 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.

@greymag
greymag merged commit 6d6dc55 into master Aug 25, 2026
1 check passed
@greymag
greymag deleted the worktree-issue12 branch August 25, 2026 10:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ability to increment minor and major version

2 participants