sr-core
Pure domain logic for sr — a single-binary semantic release tool.
Overview
sr-core provides the traits, types, and functions that power semantic versioning releases. It contains no I/O — all git operations, VCS provider calls, and shell execution are abstracted behind traits so that consumers can supply their own implementations.
Traits
| Trait | Purpose |
|---|---|
GitRepository |
Tag discovery, commit listing, tag/push operations |
VcsProvider |
Remote release creation (GitHub, GitLab, etc.) |
CommitParser |
Parse raw commits into conventional commits |
CommitClassifier |
Map commit types to bump levels and changelog sections |
ChangelogFormatter |
Render changelog entries to text |
HookRunner |
Execute lifecycle shell commands |
ReleaseStrategy |
Orchestrate plan + execute |
Key Types
| Type | Description |
|---|---|
ReleaseConfig |
Full configuration (branches, tag prefix, hooks, version files, etc.) |
ReleasePlan |
The computed next release (current version, next version, bump level, commits) |
ConventionalCommit |
A parsed conventional commit (type, scope, description, breaking flag) |
BumpLevel |
Patch, Minor, or Major |
ChangelogEntry |
A single version's changelog data (version, date, commits, compare URL) |
ReleaseError |
Unified error type for all release operations |
TrunkReleaseStrategy |
Default ReleaseStrategy implementation wiring all traits together |
Key Functions
| Function | Description |
|---|---|
determine_bump(commits, classifier) |
Compute the highest bump level from a set of conventional commits |
apply_bump(version, bump) |
Apply a bump level to a semver Version, returning the new version |
bump_version_file(path, new_version) |
Update the version field in Cargo.toml, package.json, or pyproject.toml |
Usage
Add sr-core to your Cargo.toml:
[]
= "0.1"
Building a custom release strategy
use ReleaseConfig;
use TrunkReleaseStrategy;
use ;
use DefaultChangelogFormatter;
use ShellHookRunner;
use ReleaseStrategy;
// Load configuration
let config = load.unwrap;
// Build the strategy with your own GitRepository and VcsProvider implementations
let strategy = TrunkReleaseStrategy ;
// Plan the release
let plan = strategy.plan?;
// Execute (or dry-run)
strategy.execute?;
Computing a version bump
use ;
use DefaultCommitClassifier;
use Version;
let classifier = default;
if let Some = determine_bump