From 885e1d19bdc38cab33cfe18c8357f05ad5b82905 Mon Sep 17 00:00:00 2001 From: spacebear Date: Mon, 10 Aug 2026 12:37:44 -0400 Subject: [PATCH 1/2] Add cargo-semver-checks to the release devshell The release scripts will invoke cargo-semver-checks to catch API changes that require a bigger version bump than the one declared. Provide the tool via the release devshell so the check runs identically locally and in CI, per the devshell tooling rule. --- flake.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/flake.nix b/flake.nix index 8a33ea980..e18b87f49 100644 --- a/flake.nix +++ b/flake.nix @@ -459,6 +459,7 @@ name = "release"; packages = with pkgs; [ rustToolchains.stable + cargo-semver-checks jq gnupg curl From 6d1dc3b5cb6443bb2839ec1328d0b8935f8cadaf Mon Sep 17 00:00:00 2001 From: spacebear Date: Mon, 10 Aug 2026 12:39:42 -0400 Subject: [PATCH 2/2] Check semver compliance on release bump PRs The only API gate at release time is cargo publish --dry-run, which cannot tell whether the declared bump is large enough for the API changes it ships. Run cargo-semver-checks in check-bump for each payjoin bump, comparing the crate against its version at the PR base. The base version is passed explicitly as the baseline so the comparison stays correct even when crates.io carries a newer release, such as a bump on a maintenance branch. Pre-release comparisons are skipped: semver classifies them as major bumps, which permit any change, so running the tool there proves nothing. Scope is payjoin only; payjoin-cli has no library API and payjoin-mailroom's is not yet stable. Note the tool has known false negatives (some generic, lifetime, and type-position changes), so it complements the changelog's Breaking markers rather than replacing them. --- contrib/release/check-bump.sh | 29 +++++++++++++++++++++++++---- flake.nix | 4 ++++ 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/contrib/release/check-bump.sh b/contrib/release/check-bump.sh index 7be846c98..1b43fc2ee 100755 --- a/contrib/release/check-bump.sh +++ b/contrib/release/check-bump.sh @@ -1,10 +1,11 @@ #!/usr/bin/env bash # # Pull request check. For each release crate whose version changed relative -# to the base commit, confirm the bump is consistent (check-invariants) and -# the crate still publishes (cargo publish --dry-run). No-ops when no release -# version changed. A sibling release crate not yet on crates.io is skipped, -# not failed, since a PR may bump two crates at once. +# to the base commit, confirm the bump is consistent (check-invariants), the +# crate still publishes (cargo publish --dry-run), and the bump is large +# enough for the API changes since the base version (cargo semver-checks). +# No-ops when no release version changed. A sibling release crate not yet on +# crates.io is skipped, not failed, since a PR may bump two crates at once. set -euo pipefail DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # shellcheck source=contrib/release/crates.sh @@ -56,3 +57,23 @@ for crate in "${changed[@]}"; do cargo publish --dry-run --locked -q -p "$crate" echo "$crate packages and publishes cleanly" done + +# Semver only binds between stable releases: any comparison involving a +# pre-release is classified as a major bump, which permits everything, so +# running the tool there proves nothing. Only payjoin is checked for now; +# payjoin-cli has no library API and payjoin-mailroom's is not yet stable. +for crate in "${changed[@]}"; do + [ "$crate" = "payjoin" ] || continue + new_version="$(manifest_version "$crate")" + baseline="$(version_at "$base" "$crate")" + if is_prerelease "$new_version" || is_prerelease "$baseline"; then + echo "Skipping $crate semver check for pre-release ($baseline -> $new_version)" + continue + fi + if ! crate_published "$crate" "$baseline"; then + echo "Skipping $crate semver check; baseline $baseline not on crates.io" + continue + fi + echo "Checking $crate $new_version API against $baseline" + cargo semver-checks --package "$crate" --baseline-version "$baseline" +done diff --git a/flake.nix b/flake.nix index e18b87f49..7d86c760e 100644 --- a/flake.nix +++ b/flake.nix @@ -60,6 +60,10 @@ rust-overlay.overlays.default (final: prev: { dart = nixpkgs-unstable.legacyPackages.${system}.dart; + # From unstable so it keeps pace with the rustdoc JSON format + # emitted by rust-overlay's latest stable toolchain; the + # release-branch nixpkgs version lags too far behind. + cargo-semver-checks = nixpkgs-unstable.legacyPackages.${system}.cargo-semver-checks; rustToolchains = { msrv = prev.rust-bin.stable.${msrv-version}.default; stable = prev.rust-bin.stable.latest.default;