Skip to content

fix(core,github-action): stabilize version computation and PR creation#225

Open
rickmartensnl wants to merge 1 commit intobruits:mainfrom
rickmartensnl:fix/stabilize-version-computation-and-PR-creation
Open

fix(core,github-action): stabilize version computation and PR creation#225
rickmartensnl wants to merge 1 commit intobruits:mainfrom
rickmartensnl:fix/stabilize-version-computation-and-PR-creation

Conversation

@rickmartensnl
Copy link
Copy Markdown
Contributor

What has changed?

  • sampo-core: Added run_stabilize_release, a new public function that transitions prerelease packages to stable. It uses a new private stabilize_version_from_parsed helper that strips the prerelease suffix and only applies an additional bump when the changeset requests a larger change than what the prerelease base already encodes (e.g. 0.2.7-alpha.6 + patch → 0.2.7, not 0.2.8). Added stabilize: bool to compute_plan_state and prepare_release_plan to route version computation through this helper.
  • sampo-github-action: prepare_stabilize_pr no longer calls exit_prerelease before computing the release plan. It now uses capture_stabilize_plan and run_stabilize_release, which compute the correct stable version in one step. execute_operations (Auto mode) now checks for prerelease packages when capture_release_plan returns no changes, so a stabilize PR is created even after a prerelease PR has been merged and its changesets moved to .sampo/prerelease/.

How is it tested?

  • Added test_stabilize_version_from_parsed unit test in release.rs covering patch/minor/major bumps against patch-, minor-, and major-implied prereleases, plus stable inputs.
  • Added 7 integration tests in release_tests.rs: current-changeset scenarios (Bug 1) and preserved-changeset scenarios (Bug 2), including a dry-run variant.

How is it documented?

No documentation changes needed — these are internal fixes with no user-facing API or configuration changes.

Copilot AI review requested due to automatic review settings April 3, 2026 10:30
@sampo-s-bot
Copy link
Copy Markdown

sampo-s-bot bot commented Apr 3, 2026

🧭 Changeset detected

Merging this PR will release the following updates:

sampo-core (Cargo) — patch version bump

Patch changes

  • Fixed incorrect stable version computation when stabilizing a prerelease package (e.g. 0.2.7-alpha.6 + patch now correctly produces 0.2.7 instead of 0.2.8), and fixed the stabilize PR not being created after merging a prerelease PR when all preserved changesets target packages still in prerelease.

sampo-github-action (Cargo) — patch version bump

Patch changes

  • Fixed incorrect stable version computation when stabilizing a prerelease package (e.g. 0.2.7-alpha.6 + patch now correctly produces 0.2.7 instead of 0.2.8), and fixed the stabilize PR not being created after merging a prerelease PR when all preserved changesets target packages still in prerelease.

@github-actions github-actions bot added crt:sampo-github-action Changes in Sampo's Github action crate. crt:sampo-core Changes in Sampo core logic or internal utils. labels Apr 3, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 stabilizes how stable version numbers are computed when transitioning prerelease crates to stable, and updates the GitHub Action flow so a stabilize PR can still be created when changesets were preserved under .sampo/prerelease/.

Changes:

  • Add run_stabilize_release to sampo-core, including stabilize_version_from_parsed to correctly strip prerelease suffixes without over-bumping.
  • Update sampo-github-action to compute and execute stabilization via the new core API (without calling exit_prerelease first), and to detect prerelease packages even when the normal changesets dir has no pending entries.
  • Add unit + integration tests covering stabilize scenarios (including preserved-changeset and dry-run cases).

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
crates/sampo-github-action/src/sampo.rs Adds action-layer wrappers to dry-run capture and execute stabilize releases via sampo-core.
crates/sampo-github-action/src/main.rs Ensures Auto mode can still prepare a stabilize PR when prerelease packages exist but the normal changesets dir is empty; switches stabilize PR flow to new stabilize plan/release functions.
crates/sampo-core/src/release.rs Implements run_stabilize_release, threads a stabilize flag into planning, and adds stabilize_version_from_parsed.
crates/sampo-core/src/release_tests.rs Adds integration tests for stabilize behavior across current/preserved changesets and dry-run.
crates/sampo-core/src/lib.rs Re-exports run_stabilize_release.
.sampo/changesets/virtuous-lord-vellamo.md Records the fix as a patch changeset for core + action crates.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +623 to 626
let plan = sampo::capture_stabilize_plan(workspace)?;
if !plan.has_changes {
println!(
"No stable release changes detected after exiting pre-release. Skipping stabilize PR.",
);
println!("No stable release changes detected. Skipping stabilize PR.");
git::git(
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

After removing the exit_prerelease call, prepare_stabilize_pr still collects prerelease_packages but no longer uses it, which will produce an unused-variable warning (and can break builds if warnings are denied). Remove the binding, prefix it with _, or use it (e.g., for logging).

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

crt:sampo-core Changes in Sampo core logic or internal utils. crt:sampo-github-action Changes in Sampo's Github action crate.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants