From fcbb64dbab63c8b101709c273c53720b5fb507bc Mon Sep 17 00:00:00 2001 From: Jeff Martin Date: Tue, 8 Sep 2026 13:26:33 -0700 Subject: [PATCH] Require an explicit release channel Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- RELEASING.md | 6 +++--- script/release | 21 ++++++++++----------- script/release_test | 7 ++++++- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/RELEASING.md b/RELEASING.md index 42bad2a..3c882ab 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -10,13 +10,13 @@ standalone module so consumers can import it on its own. From a clean, current `main`, preview the next release: ```sh -RELEASE_DRY_RUN=1 script/release patch +RELEASE_DRY_RUN=1 script/release patch --stable ``` Then cut it: ```sh -script/release patch +script/release patch --stable ``` To preview a release candidate instead: @@ -32,7 +32,7 @@ script/release patch --rc ``` The first candidate is `go/vX.Y.Z-rc.1`; repeating the same bump increments -`rc.N`. Run the bump without `--rc` to publish the stable `go/vX.Y.Z`. +`rc.N`. Use `--stable` to publish the stable `go/vX.Y.Z`. Use `patch` for compatible fixes, `minor` for compatible additions, and `major` for breaking changes. diff --git a/script/release b/script/release index da50c6c..d529f35 100755 --- a/script/release +++ b/script/release @@ -3,7 +3,7 @@ # Cut a release tag for the Go sub-module. # # Usage: -# script/release [--rc] +# script/release <--stable|--rc> # # The next version is computed from the latest go/vX.Y.Z tag and the chosen # bump. Maintainers run this locally to validate and push an annotated tag. @@ -174,21 +174,20 @@ cut_tag() { main() { cd "$(dirname "$0")/.." + [ "$#" -eq 2 ] || + die "usage: script/release <--stable|--rc>" + local bump="${1:-}" case "$bump" in patch | minor | major) ;; - *) die "usage: script/release [--rc]" ;; + *) die "usage: script/release <--stable|--rc>" ;; esac - local prerelease=0 - case "$#" in - 1) ;; - 2) - [ "$2" = "--rc" ] || - die "usage: script/release [--rc]" - prerelease=1 - ;; - *) die "usage: script/release [--rc]" ;; + local prerelease + case "$2" in + --stable) prerelease=0 ;; + --rc) prerelease=1 ;; + *) die "usage: script/release <--stable|--rc>" ;; esac cut_tag "$bump" "$prerelease" diff --git a/script/release_test b/script/release_test index 762dfdd..15b4f6f 100755 --- a/script/release_test +++ b/script/release_test @@ -56,9 +56,14 @@ git push --quiet origin refs/tags/go/v1.2.4-rc.1 output="$(RELEASE_DRY_RUN=1 script/release patch --rc)" [[ "$output" == *"Cutting go/v1.2.4-rc.2 "* ]] -output="$(RELEASE_DRY_RUN=1 script/release patch)" +output="$(RELEASE_DRY_RUN=1 script/release patch --stable)" [[ "$output" == *"Cutting go/v1.2.4 "* ]] +if RELEASE_DRY_RUN=1 script/release patch >/dev/null 2>&1; then + echo "expected missing release channel to fail" >&2 + exit 1 +fi + ancestor="$(git rev-parse HEAD)" tree="$(git rev-parse "${ancestor}^{tree}")" descendant="$(printf 'descendant\n' | git -c user.name=test -c user.email=test@example.com commit-tree "$tree" -p "$ancestor")"