fix: derive release kind from the tag, not a caller-supplied PR body field - #221
Conversation
…field finalize-release.sh read "Release kind" from the Copybara sync PR body, defaulting to patch when missing and only ever promoting patch->minor when PATCH==0. The private circle-chain-reth repo's public-release-handoff workflow just dropped that field from the PR body entirely (its own release_kind input had the same drift problem: a caller-supplied kind could disagree with the tag it described), so every release PR now silently classifies as patch/minor-by-promotion, misclassifying major (X.0.0) releases as minor. Derive EFFECTIVE_RELEASE_KIND directly from the tag's MAJOR/MINOR/PATCH fields instead, matching the fix already applied on the private side. Also guards `main "$@"` behind a BASH_SOURCE check so the parsing logic can be sourced and unit tested, and adds test-finalize-release.sh covering the patch/minor/major derivation and the base-branch validation.
|
The fix is correct and the motivation is well-explained. A few observations after reading through both files. Derivation logic — decision table
All three cases are mutually exclusive and exhaustive given the regex guard Two missing test casesThe new 1. Patch release targeting test_patch_rejects_main_base() {
PR_BODY="$(sync_body v0.7.3 release/0.7)"
PR_BASE_REF="main"
PR_HEAD_REF="sync/v0_7_3"
assert_dies "patch release PR targeting main must fail" parse_release_metadata
}2. Minor release targeting its own release branch instead of test_minor_rejects_release_branch_base() {
PR_BODY="$(sync_body v0.8.0 release/0.8)"
PR_BASE_REF="release/0.8"
PR_HEAD_REF="sync/v0_8_0"
assert_dies "minor release PR targeting release branch instead of main must fail" parse_release_metadata
}The latter matters specifically because the original bug involved a minor/major classification error — the base-branch check is the guard that would have caught a misclassified major release reaching the wrong base. Having it exercised for
|
Summary
finalize-release.shreadRelease kindfrom the sync PR body, defaulting topatchwhen missing and only ever promotingpatch->minorwhenPATCH==0.Release kindfield in the body, so every release PR now silently classifies aspatch/minor-by-promotion, misclassifying major (X.0.0) releases asminor.EFFECTIVE_RELEASE_KINDpurely from the tag'sMAJOR/MINOR/PATCHfields instead of trusting a PR-body label at all.minor/majorwas already identical code, and nothing currently consumes therelease_kindoutput), but it was reporting the wrong value and would misfire silently if anything starts consuming that output (changelog generation, notifications, etc.).Changes
.github/scripts/finalize-release.sh: removeRelease kindPR-body parsing/validation; derive release kind from tag shape; guardmain "$@"behind aBASH_SOURCEcheck so the parsing logic is sourceable for tests..github/scripts/test-finalize-release.sh(new): covers patch/minor/major derivation from the tag alone (noRelease kindfield in the test PR bodies) and the base-branch validation for major releases.Test plan
bash .github/scripts/test-finalize-release.shpasses locallyshellcheck .github/scripts/finalize-release.sh .github/scripts/test-finalize-release.shcleanci.yml) on this PR