diff --git a/tasks/release-plz b/tasks/release-plz index cc1df63e..3abba50a 100755 --- a/tasks/release-plz +++ b/tasks/release-plz @@ -2,12 +2,33 @@ # 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 + 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 @@ -15,21 +36,30 @@ if ! echo "$released_versions" | grep -q "^v$cur_version$"; then 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/**')" 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