-
-
Notifications
You must be signed in to change notification settings - Fork 18
feat: Add automatic version bumping based on conventional commits #656
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
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
Add automatic semantic version calculation triggered by `craft prepare auto`. Analyzes commits since the last tag using release config categories with a new `semver` field to determine the appropriate version bump (major/minor/patch). Key changes: - Add `semver` field to release config categories (major/minor/patch) - Update DEFAULT_RELEASE_CONFIG with conventional commit semver mappings - Create autoVersion.ts with BumpType enum for efficient max comparison - Add requiresMinVersion() helper to gate feature (requires minVersion >= 2.14.0) - Update prepare command to accept "auto" keyword The system finds the highest bump type across matched commits with early exit when a major bump is found. Throws an error if no commits match categories with semver fields defined.
Implement the previously stubbed version bump types feature. Users can now run: - `craft prepare major` - bump major version - `craft prepare minor` - bump minor version - `craft prepare patch` - bump patch version Like auto-versioning, this requires minVersion >= 2.14.0 in .craft.yml. Also update README with comprehensive documentation for all version specification options including auto-versioning and bump types.
Refactor getAutoVersion to getAutoBumpType which returns a BumpType enum instead of the computed version string. This allows prepareMain to handle both "auto" and explicit bump types (major/minor/patch) with unified logic: 1. Get latest tag 2. Determine bump type (from arg or commit analysis) 3. Calculate new version using calculateNextVersion This increases code reuse and simplifies the prepare command logic.
Replace BumpType enum with simple string literal type and BUMP_TYPES array ordered by priority (major > minor > patch). This allows: 1. Direct use as semver.inc() argument (no mapping needed) 2. Priority lookup via array index (first found = highest priority) 3. Single source of truth for bump types shared between autoVersion and prepare The analyzeCommitsForBump function now: - Collects found bump types in a Set during commit iteration - Early exits on 'major' (no need to check more) - Returns first match from BUMP_TYPES array (highest priority)
…ate work Previously, auto-versioning and changelog generation each independently: - Fetched commits since the last tag - Made GitHub API calls to get PR/label metadata - Iterated through commits to categorize them This was wasteful when both features are used together. Changes: - Move BUMP_TYPES and BumpType to changelog.ts (single source of truth) - Have generateChangesetFromGit return ChangelogResult with both: - changelog: the formatted changelog string - bumpType: the highest version bump determined from commits - Add matchCommitToCategory (exported) returning full NormalizedCategory - Simplify autoVersion.ts to just re-export types and provide: - calculateNextVersion: semver calculation - getChangelogWithBumpType: wrapper that validates and returns result - Update prepareMain to cache changelog result when using auto-versioning and pass it to prepareChangelog to avoid regenerating This eliminates duplicate GitHub API calls when using 'craft prepare auto' with changelog generation enabled.
BYK
commented
Dec 10, 2025
- BUMP_TYPES: Use object with numeric priorities instead of array - Use min() for bump type comparison instead of Set - Fix matchedCommitsWithSemver to track actual count - Memoize generateChangesetFromGit (caches promise for concurrent calls) - ValidatedChangelogResult type with non-null bumpType - Remove useless BUMP_TYPES tests - Fix logger: currentVersion can never be empty
- Define BumpType first, then BUMP_TYPES as Map<BumpType, number> - Use .has() and .get() instead of 'in' operator (avoids prototype issues) - Add clearChangesetCache() for testing memoization
BYK
commented
Dec 10, 2025
- getChangelogWithBumpType no longer throws - returns null bumpType instead - Added validateBumpType() for callers that need to enforce bump type - Changed changesetCache to Map for proper cleanup - Added isBumpType() type guard for safe BumpType checks - Clear memoization cache in tests to prevent stale results
sentrivana
approved these changes
Dec 11, 2025
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.
Summary
Add automatic semantic version calculation and version bump types, triggered by:
craft prepare auto- determine version from conventional commit analysiscraft prepare major- bump major versioncraft prepare minor- bump minor versioncraft prepare patch- bump patch versionAll options require
minVersion: '2.14.0'(or higher) in.craft.yml.Key changes
semverfield to release config categories (major/minor/patch)DEFAULT_RELEASE_CONFIGwith conventional commit semver mappings:majorminorpatchautoVersion.tswithBumpTypeenum for efficient max comparison and early exitrequiresMinVersion()helper to gate featureautoand bump type keywordsBehavior
Auto-versioning: Finds the highest bump type across matched commits with early exit when a major bump is found. Throws an error if no commits match categories with semver fields defined.
Version bump types: Gets the latest tag and applies the specified bump (major/minor/patch) using the semver library.
Usage
Requires
minVersion: '2.14.0'(or higher) in.craft.yml.