Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 34 additions & 4 deletions tasks/release-plz
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,64 @@
# shellcheck shell=bash
set -euxo pipefail

# clap_usage is versioned by hand and released on its own cadence, so it needs
# its own check: the usage-lib release cycle below would otherwise never publish
# it. That omission is why it sat unpublished at 2.0.3 from 2025-01 to 2026-07.
#
# It depends on usage-lib at the workspace version, so it can only be published
# once that version is on crates.io — hence a function called in dependency
# order rather than a block at the top of the script.
publish_clap_usage_if_needed() {
local version
version="$(cargo pkgid clap_usage | cut -d# -f2 | cut -d@ -f2)"
if curl -fsS https://index.crates.io/cl/ap/clap_usage |
grep -q "\"vers\":\"$version\""; then
return
fi
echo "Releasing clap_usage $version"
if [ "${usage_dry_run:-}" != 1 ]; then
cargo publish -p clap_usage
Comment thread
greptile-apps[bot] marked this conversation as resolved.
fi
}

released_versions="$(git tag --list | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)?$')"
cur_version="$(cargo pkgid usage-lib | cut -d# -f2 | cut -d@ -f2)"
if ! echo "$released_versions" | grep -q "^v$cur_version$"; then
echo "Releasing $cur_version"
if [ "${usage_dry_run:-}" != 1 ]; then
cargo publish -p usage-lib
publish_clap_usage_if_needed
cargo publish -p usage-cli
git tag "v$cur_version"
git push --tags
fi
exit 0
fi

version="$(git cliff --bumped-version)"
# usage-lib's current version is already released, so clap_usage's dependency
# is satisfied; catch it up if it is behind.
publish_clap_usage_if_needed

version="$(git cliff --bumped-version --include-path 'lib/**' --include-path 'cli/**')"

if [ "v$cur_version" == "$version" ]; then
echo "No usage-lib/usage-cli changes since $version; nothing to release"
exit 0
fi

if [ "${usage_dry_run:-}" == 1 ]; then
echo "version: $version"
changelog="$(git cliff --bump --unreleased --strip all)"
changelog="$(git cliff --bump --unreleased --strip all --include-path 'lib/**' --include-path 'cli/**')"
Comment thread
cursor[bot] marked this conversation as resolved.
echo "changelog: $changelog"
exit 0
fi

# Generate changelog using git-cliff (LLM editorialization happens in release.yml after merge)
git cliff --bump -o CHANGELOG.md
git cliff --bump -o CHANGELOG.md --include-path 'lib/**' --include-path 'cli/**'

# Get the unreleased notes for PR body
# Strip version header since PR title already has version
PR_BODY="$(git cliff --bump --unreleased --strip all | tail -n +3)"
PR_BODY="$(git cliff --bump --unreleased --strip all --include-path 'lib/**' --include-path 'cli/**' | tail -n +3)"

cargo set-version "${version#v}" --exclude clap_usage
mise run render
Expand Down