Predict the next release version without semantic-release's own orchestrator - #4
Merged
Merged
Conversation
…tity and predictNextVersion Both need the same "read the semantic-release-managed version from package.json" logic. Extract it into its own module, alongside the default v<version> tag-name convention, so the invariant lives in one place rather than being copied.
…ity kind
resolvePredictedIdentity used to return BuildIdentity & { predicted?:
boolean }, bolting an optional flag onto a two-value kind rather than
naming the third real state directly. A caller had to check kind ===
'commit' and then separately check predicted, when there are really
three states to switch on: a confirmed release, a predicted-but-not-
yet-tagged version, and a plain unreleased commit with no prediction
available. DisplayIdentity's kind now has all three as its own literal
values, and predicted is gone.
BREAKING CHANGE: resolvePredictedIdentity's return type is now
DisplayIdentity (kind: 'release' | 'predicted' | 'commit'), not
BuildIdentity & { predicted?: boolean }. An unreleased build with a
prediction now reports kind: 'predicted' instead of kind: 'commit' with
a separate predicted: true field.
… orchestrator semanticRelease() verifies push access to the remote as part of resolving branches before analysis ever runs, on every call including dryRun -- slow, and needing credentials a prediction has no real reason to hold. predictNextVersion calls @semantic-release/commit-analyzer's own analyzeCommits hook directly instead: no network, no registry lookups, no push check. It takes analyzeCommits as a parameter rather than importing the module itself, so it stays a pure, easily-fakeable function of its own arguments; loadCommitAnalyzer is the tested way to obtain a real implementation, kept as its own function since that module ships no types and analyzeCommits isn't part of its documented public API. @semantic-release/commit-analyzer is declared as an optional peer dependency: not required for resolveBuildIdentity/ resolvePredictedIdentity, only for loadCommitAnalyzer/ predictNextVersion.
Most tests in this package spawn several real git subprocesses per test (createTestRepo, tag(), commit(), the resolve/predict functions themselves), and predict-next-version's own tests additionally load and run the real @semantic-release/commit-analyzer package -- both genuinely I/O- and process-bound. Vitest's 5000ms default assumes pure in-memory JS and was already too tight for this, flaking under any real system load.
Mearman
marked this pull request as ready for review
September 8, 2026 07:56
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
🎉 This PR is included in version 2.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.
Adds
predictNextVersion+loadCommitAnalyzer, and refinesresolvePredictedIdentity's return type.What this does
predictNextVersion(repoRoot, releaseRules, analyzeCommits, options?)predicts the version a repo's next release would be, from commits since its last tagged release, without runningsemanticRelease()'s own top-level orchestrator -- that verifies push access to the remote as part of resolving branches before analysis ever runs, on every call includingdryRun, which is slow and needs credentials a prediction has no real reason to hold. It calls@semantic-release/commit-analyzer's ownanalyzeCommitshook directly instead.analyzeCommitsis a caller-supplied parameter, not something this package imports itself --@semantic-release/commit-analyzerships no types andanalyzeCommitsisn't part of its documented public API, so loading it safely is a toolchain-specific concern.loadCommitAnalyzer()is the tested, correct way to get a real one (declared as an optional peer dependency);predictNextVersionitself stays a pure, easily-fakeable function of its own arguments.Breaking change
resolvePredictedIdentitynow returnsDisplayIdentity(kind: 'release' | 'predicted' | 'commit') instead ofBuildIdentity & { predicted?: boolean }. An unreleased build with a prediction now reportskind: 'predicted'directly rather thankind: 'commit'plus a separatepredicted: trueflag -- three real states get three real values instead of a bolted-on boolean.Also includes a small extraction (shared
package.jsonversion reading betweenresolveBuildIdentityandpredictNextVersion) and a fix to vitest's per-test timeout, which was too tight for tests that spawn real git subprocesses or load the real commit-analyzer package.