# cargo-release configuration (#257).
# Reference: https://github.com/crate-ci/cargo-release/blob/master/docs/reference.md
#
# Releases are TAG-TRIGGERED. Pushing a `v*` tag fires
# .github/workflows/release.yml, which builds the cross-platform binaries,
# publishes to crates.io (publish-crate job), creates the GitHub Release, and
# bumps the Homebrew formula.
#
# cargo-release therefore owns only the local, error-prone prep — bump the
# version and roll the CHANGELOG into one commit. It does NOT publish, tag, or
# push, because:
#   - publish: crates.io is owned by CI; publishing here too would double-publish.
#   - tag/push: `main` is protected (PR-only), so the prep commit lands via a PR
#     and the `v*` tag is cut on the merged commit. See RELEASING.md.

# Only cut releases from main, a long-lived release/X.x branch (patch/minor),
# or a short-lived chore/release-<version> prep branch (minor/major from main).
allow-branch = ["main", "release/*", "chore/release-*"]

# crates.io publish is owned by the publish-crate job in release.yml.
publish = false

# The v* tag is created on the merged main commit (see RELEASING.md), not by
# cargo-release, so it matches what actually landed on the protected branch.
tag = false
push = false

# Documents the tag format CI triggers on (the `v*` filter in release.yml).
tag-name = "v{{version}}"

pre-release-commit-message = "chore(release): {{version}}"

# All workspace crates share the same version (bumped together on every release).
# This satisfies find_shared_versions() so workspace_commit can resolve {{version}}
# without the "Unrendered {{version}}" warning.
shared-version = true

# Sync website/docs/changelog.md from the just-updated CHANGELOG.md so the
# docs_changelog_in_sync_with_root test passes in the release commit.
# For pre-release versions (rc/beta/alpha), also roll the [Unreleased]
# CHANGELOG section into a versioned section — cargo-release skips
# pre-release-replacements for pre-release suffix versions, so the
# script does the same replacements manually.
pre-release-hook = ["bash", "-c", "${WORKSPACE_ROOT}/scripts/roll-prerelease-changelog.sh {{version}}; ${WORKSPACE_ROOT}/scripts/sync-changelog-doc.sh"]

# Keep-a-Changelog rollover. On `cargo release <level>` this turns the
# `[Unreleased]` section into a dated, versioned section and re-seeds a fresh
# `[Unreleased]` + compare link for the next cycle. Pattern from the
# cargo-release FAQ (docs/faq.md#maintaining-changelog).
pre-release-replacements = [
  { file = "CHANGELOG.md", search = "Unreleased", replace = "{{version}}", min = 1 },
  { file = "CHANGELOG.md", search = "\\.\\.\\.HEAD", replace = "...v{{version}}", exactly = 1 },
  { file = "CHANGELOG.md", search = "ReleaseDate", replace = "{{date}}", exactly = 1 },
  { file = "CHANGELOG.md", search = "<!-- 3.0 next-header -->", replace = "<!-- 3.0 next-header -->\n\n## [Unreleased] - ReleaseDate", exactly = 1 },
  { file = "CHANGELOG.md", search = "<!-- next-url -->", replace = "<!-- next-url -->\n[Unreleased]: {{repository}}/compare/v{{version}}...HEAD", exactly = 1 },
]
