Skip to content

feat(release): add --no-wait/--finalize/--non-interactive flags for agent-driven releases - #1360

Merged
lklimek merged 5 commits into
v1.6-devfrom
chore/release-script-agent-friendly
Jun 22, 2026
Merged

lklimek merged 5 commits into
v1.6-devfrom
chore/release-script-agent-friendly

Conversation

@lklimek

@lklimek lklimek commented Jun 19, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

The release script's blocking merge-wait (polling every 5 s until the PR is merged) is hostile to agents and CI pipelines — a foreground Bash call hits the tool timeout and backgrounding the process gets it reaped. This was directly observed while cutting v1.6.0-dev.2 with an agent driver.

This PR adds three purely additive flags. Running with no new flags produces identical behavior to today.

New flags

Flag Alias Effect
--no-wait --stop-after-pr Run validate → changelog (git-cliff) → version bump → branch commit+push → open PR, then print RELEASE_PR=<url> and exit 0. Skips the blocking wait and draft-release step.
--finalize --create-release Skip prep entirely. Verify the release_<ver> PR is MERGED (clear error if not), then create the draft GitHub release. Idempotent — if the tag/release already exists, reports the URL and exits cleanly. Emits RELEASE_DRAFT=<url>.
--non-interactive --yes Auto-accept every confirmation prompt; never block on stdin. Implied by both --no-wait and --finalize.

Machine-parseable RELEASE_PR=<url> and RELEASE_DRAFT=<url> lines are also emitted in the default interactive path (additive, alongside the existing human-readable SUCCESS: lines).

Agent / CI two-call flow

# Step 1 — prep: generate changelog, bump version, open PR, exit 0
git checkout v1.6-dev
./scripts/release/release.sh --release=1.6.0-dev.3 --no-wait
# stdout: RELEASE_PR=https://github.com/dashpay/tenderdash/pull/NNN

# (human or CI merges the PR)

# Step 2 — finalize: verify merged, create draft release
./scripts/release/release.sh --release=1.6.0-dev.3 --finalize
# stdout: RELEASE_DRAFT=https://github.com/dashpay/tenderdash/releases/tag/v1.6.0-dev.3

Validation (static only — release script was NOT executed)

  • bash -n scripts/release/release.sh → PASS
  • shellcheck scripts/release/release.sh → only pre-existing SC2035 info on sha256sum *.tar.gz glob (unchanged from before this PR)
  • Diff review: default path unchanged; each new flag branches cleanly off the main flow; --finalize idempotency relies on gh release view existence check before calling gh release create

Files changed

  • scripts/release/release.sh — new flag parsing, validateFinalize, createReleaseIdempotent, restructured main block with section headers
  • RELEASES.md — new "Agent / CI two-call flow" section documenting the flags and the two-call pattern

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation

    • Added new release workflow documentation including a two-phase process for automated CI/release scenarios with validation guides.
  • Chores

    • Enhanced release script with new capabilities for non-blocking workflows, pre-release validation, and machine-readable outputs for automation systems.

…sh for agent-driven releases

The release script's blocking merge-wait (a 5-second poll loop until the
release PR is merged) is hostile to agents and CI pipelines — a foreground
Bash call hits the tool timeout and backgrounding the process gets it reaped.
Observed while cutting v1.6.0-dev.2.

New flags (purely additive; running with no new flags is identical to today):

  --no-wait / --stop-after-pr
      Run the full prep phase (validate → git-cliff changelog → version bump
      → release branch commit+push → open PR), emit a machine-parseable
      'RELEASE_PR=<url>' line to stdout, then exit 0.  Skips the blocking
      wait and the draft-release step.  Implies --non-interactive.

  --finalize / --create-release
      Skip prep entirely.  Verify the release_<ver> PR is MERGED (clear
      error if not), then create the DRAFT GitHub release.  Idempotent: if
      the tag/release already exists it reports the URL and exits cleanly.
      Emits 'RELEASE_DRAFT=<url>' to stdout.  Implies --non-interactive.

  --non-interactive / --yes
      Auto-accept every confirmation prompt; never block on stdin.
      Automatically implied by --no-wait and --finalize.

Agent two-call flow:
  # Step 1 — prep and open PR:
  ./scripts/release/release.sh --release=1.6.0-dev.3 --no-wait
  # grep output: RELEASE_PR=https://...

  # Step 2 — after PR is merged:
  ./scripts/release/release.sh --release=1.6.0-dev.3 --finalize
  # grep output: RELEASE_DRAFT=https://...

Also adds machine-parseable RELEASE_PR= / RELEASE_DRAFT= lines to the
default interactive path (additive; they appear alongside the existing
human-readable SUCCESS lines).

RELEASES.md updated with a new "Agent / CI two-call flow" section documenting
the flags and the two-call pattern.

Validated: bash -n (syntax pass), shellcheck (only pre-existing SC2035 info
on sha256sum glob, unchanged from before this commit).

Co-authored-by: Lukasz Klimek <[email protected]>
@lklimek
lklimek requested a review from QuantumExplorer as a code owner June 19, 2026 10:55
@coderabbitai

coderabbitai Bot commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f92fd701-cfef-4c15-add6-b7d9377d4383

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

release.sh gains four new flags (--no-wait, --finalize, --non-interactive, --dry-run) that implement a two-call, non-blocking release flow. The script emits machine-parseable RELEASE_PR= and RELEASE_DRAFT= stdout markers, adds idempotent draft release creation, guards cleanup from running in finalize/dry-run modes, and RELEASES.md documents the full workflow.

Changes

Two-call non-blocking release flow

Layer / File(s) Summary
New flags: parsing, cleanup guard, and debug output
scripts/release/release.sh
Argument parsing sets NO_WAIT, FINALIZE, NON_INTERACTIVE, and DRY_RUN; cleanup() is skipped when FINALIZE or DRY_RUN is active; a debug line prints all resolved mode flags; help text and examples document all new flags.
Preflight and validation functions
scripts/release/release.sh
Adds validateFinalize, preflight (Docker + auth + push-credential dry-run probe, non-fatal in --dry-run), and preflightFinalize (lightweight gh-only validation).
Idempotent draft release creation
scripts/release/release.sh
createReleaseIdempotent checks for an existing GitHub release by tag, emits RELEASE_DRAFT=<url> in all cases, and skips re-creation when a release already exists.
Main control flow and stdout markers
scripts/release/release.sh
Main entry point enforces mutual exclusivity of --no-wait/--finalize, branches early for --finalize (verify merged + idempotent draft) and --dry-run (preview + exit), emits RELEASE_PR=<url> and RELEASE_DRAFT=<url> machine-parseable markers, and exits immediately after --no-wait cleanup.
RELEASES.md documentation
RELEASES.md
Documents the agent/CI two-call non-blocking workflow with commands, flag explanations, expected stdout, do-not-background caution, prerequisites, and a --dry-run pre-check command.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • dashpay/tenderdash#1336: Directly modifies scripts/release/release.sh error/cleanup behavior and RELEASES.md, the same files and concerns addressed by this PR.

Suggested reviewers

  • QuantumExplorer

Poem

🐇 Hop once to open the PR with flair,
RELEASE_PR=url floats in the air.
The merge lands softly, the agents take note,
--finalize jumps in to draft every quote.
RELEASE_DRAFT=url — the ribbon is tied,
Two calls, no blocking, the bunny's inside! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 30.77% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title accurately reflects the main change: adding three new flags (--no-wait, --finalize, --non-interactive) to enable agent-driven releases in the release script.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/release-script-agent-friendly

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@thepastaclaw

thepastaclaw commented Jun 19, 2026 •

Copy link
Copy Markdown

✅ Review complete (commit b744eca)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Tenderdash release automation to better support agent/CI-driven releases by splitting the current “prep + wait-for-merge + draft-release” flow into two optional, non-blocking phases and by emitting machine-parseable markers for downstream automation.

Changes:

  • Add --no-wait/--stop-after-pr to stop after opening the release PR and print RELEASE_PR=<url>.
  • Add --finalize/--create-release to verify the release PR is merged and create (idempotently) the draft GitHub release, printing RELEASE_DRAFT=<url>.
  • Document the two-call agent/CI flow in RELEASES.md.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
scripts/release/release.sh Adds new flags, finalize-mode validation and idempotent draft release creation, and emits RELEASE_PR= / RELEASE_DRAFT= markers.
RELEASES.md Documents the non-blocking two-call release workflow and the new CLI flags.

Comment thread RELEASES.md Resolved
Comment thread scripts/release/release.sh Resolved
Comment thread scripts/release/release.sh Resolved
Comment thread scripts/release/release.sh Resolved

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

Two real blocking issues in the new --finalize/--no-wait/--non-interactive flow: error() in --finalize still runs the destructive cleanup() helper (contradicts 'safe from any checkout' docs in RELEASES.md), and --non-interactive is never wired into gh release delete, so --cleanup --no-wait can still block on stdin. Plus one suggestion (mutual-exclusivity) and two nitpicks. The default interactive path is unaffected.

🔴 2 blocking | 🟡 1 suggestion(s) | 💬 2 nitpick(s)

1 additional finding(s) omitted (not in diff).

🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `scripts/release/release.sh`:
- [BLOCKING] scripts/release/release.sh:475-488: --finalize errors trigger cleanup() and mutate the caller's checkout
  RELEASES.md documents `--finalize` as runnable from any checkout because it 'only talks to the GitHub API'. However, any error inside this branch — most obviously the not-yet-merged check at line 480, plus the auth check at line 215 — calls `error()` (line 13-18), which unconditionally calls `cleanup()` (line 446). `cleanup()` runs `git checkout --quiet -- ${REPO_DIR}/CHANGELOG.md`, `git checkout SOURCE_BRANCH`, `git branch -D RELEASE_BRANCH`, and `make clean`. If an operator runs `release.sh --release=X.Y.Z --finalize` from an unrelated checkout (which the docs explicitly invite) and the PR isn't merged yet, the script will: discard local CHANGELOG.md edits, switch the current branch, attempt to delete a `release_X.Y.Z` branch that may belong to unrelated work, and run `make clean` on the wrong tree. Either gate `cleanup()` inside `error()` (e.g. skip when `FINALIZE=yes`), or give the finalize branch its own bail-out helper that prints and exits without touching the working tree.
- [BLOCKING] scripts/release/release.sh:323-326: --non-interactive is never consulted; gh release delete still prompts and blocks --cleanup --no-wait
  `--non-interactive`/`--yes` sets `NON_INTERACTIVE=yes` (line 136) and is implied by `--no-wait`/`--finalize` (lines 468-470), but no code path reads `${NON_INTERACTIVE}`. The flag's documented contract ('Assume "yes" to every confirmation prompt; never block on stdin', lines 52-54, plus the agent/CI flow in RELEASES.md) is therefore not enforced. The concrete consequence: `deleteRelease` (line 323-330) calls `gh release delete "v${NEW_PACKAGE_VERSION}"` without `--yes`, which by default prompts on stdin for confirmation. Running `release.sh --release=X.Y.Z --cleanup --no-wait` will hang waiting for input despite `--no-wait` implying non-interactive. Either wire `NON_INTERACTIVE` into this call site (and any future prompt) or drop the flag and its documentation. Minimum fix is in the suggestion.
- [SUGGESTION] scripts/release/release.sh:467-488: No mutual-exclusivity check between --no-wait and --finalize
  If both `--no-wait` and `--finalize` are passed (an easy slip when an agent driver assembles the command-line incrementally), the `--finalize` branch at line 475 runs first and exits at line 487; the `--no-wait` block at line 514 never executes. The two flags express opposite intents ('stop before merge wait' vs 'only run after merge'); a contradictory invocation should fail fast in `parseArgs` (or just before line 468) rather than silently picking one half of the work.

Comment thread scripts/release/release.sh Resolved
Comment thread scripts/release/release.sh Resolved
Comment thread scripts/release/release.sh Resolved
Comment thread scripts/release/release.sh Resolved
lklimek and others added 3 commits June 19, 2026 13:14
…releases

Add three robustness improvements to scripts/release/release.sh:

1. --dry-run flag: runs validate → git-cliff changelog generation, prints
   DRY-RUN: TMVersionDefault preview and the RELEASE_PR=/RELEASE_DRAFT= lines
   it would emit, then exits 0.  An EXIT trap restores CHANGELOG.md so the
   working tree is always left clean.  No commit, push, PR, tag, or release
   action is taken.  Implies --non-interactive.

2. Preflight checks (preflight / preflightFinalize functions): run before any
   mutating or remote step.  Checks: docker info reachable (git-cliff needs it),
   gh auth status authenticated, and a git push --dry-run probe to origin for
   the release branch (catches missing creds / token scope before any commit).
   In --dry-run the push probe is informational and non-fatal.  --finalize gets
   a lighter subset (gh auth only; no docker or push needed for API-only work).

3. RELEASES.md cautions section: documents that the default blocking invocation
   must never be backgrounded in automation, lists prerequisites (Docker, gh
   auth, push credentials), and shows the --dry-run pre-check workflow.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…po context

Address all 8 bot review threads (4 Copilot + 4 thepastaclaw) on PR #1360:

1. cd into REPO_DIR after arg parsing (Copilot ⭐ / thepastaclaw nitpick)
   - realpath-normalize REPO_DIR (handles -C relative/path)
   - cd into it before configureFinal so all git/gh/make commands operate
     against the intended checkout regardless of caller's CWD
   - move NON_INTERACTIVE implication before configureFinal so the debug
     line reflects the actual runtime state (thepastaclaw nitpick)

2. cleanup() guard for --finalize and --dry-run (thepastaclaw 🔴 blocking)
   - In --finalize/--dry-run the working tree is never modified, so cleanup()
     now returns immediately — prevents error paths from clobbering the
     caller's checkout (branch switch, branch deletion, make clean)

3. validateFinalize: add gh repo view check (Copilot)
   - Explicit repo-resolution check before any gh API call; opaque gh
     failures are replaced by an actionable error pointing at GH_REPO
   - Reword comment: stop claiming finalize is "git/checkout independent"
     (Copilot + thepastaclaw)

4. Mutual-exclusivity guard: --no-wait + --finalize (thepastaclaw 🟡)
   - Detect contradictory invocation early in parseArgs main flow and
     error with a clear message before any work begins

5. Docs: clarify --finalize repo-context requirement (Copilot)
   - RELEASES.md two-call flow step 2: replace "Can be run from any
     checkout; only GitHub auth is required" with accurate statement
   - Flags table --finalize row: note git-checkout / GH_REPO requirement
   - displayHelp --finalize description and step 2 example: same fix

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…-run

Per reviewer spec: gate the cleanup call inside error() — `if [[ -z
FINALIZE && -z DRY_RUN ]]; then cleanup; fi` — so that error paths in
--finalize and --dry-run never run cleanup()'s branch-switch / branch-
deletion / make-clean against the caller's working tree.

Remove the earlier equivalent guard from cleanup() itself; cleanup() is
clean for direct calls from the standard prep path.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@RELEASES.md`:
- Around line 147-149: The documentation for the `--dry-run` flag in the
Pre-check section incorrectly states that it runs "without touching any remote,"
but the script actually performs read-only remote operations such as
authentication checks and validation fetches. Modify the wording to clarify that
the dry-run does not make any remote mutations or changes, rather than claiming
no remote interaction occurs at all. Replace "without touching any remote" with
language like "without remote mutations" to accurately reflect that read-only
remote checks still happen during the preflight validation.

In `@scripts/release/release.sh`:
- Around line 266-271: The error message in the git push credential probe block
includes raw stderr output from the git push command (the `push_out` variable)
which could potentially contain embedded credentials if they exist in the remote
URL. Remove the raw output (`${push_out}`) from the `msg` variable assignment to
prevent credential leakage in logs. Keep the descriptive message about checking
SSH keys or tokens, but do not append the unfiltered git command output to the
logged message.
- Around line 576-582: The validate function is being called within the DRY_RUN
block and performs a fast-forward merge of origin/${SOURCE_BRANCH}, which
mutates the local branch state and violates the preview-only nature of dry-run
mode. Either pass the DRY_RUN flag (or a similar parameter) to the validate
function so it can skip the merge operation when in dry-run mode, or
alternatively add a git checkout restore command in the EXIT trap to revert the
branch to its original state after validate completes, similar to how
CHANGELOG.md is restored.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: eed7c302-0266-4133-be98-6b2199a5431c

📥 Commits

Reviewing files that changed from the base of the PR and between 652c5cf and 8948a67.

📒 Files selected for processing (2)
  • RELEASES.md
  • scripts/release/release.sh

Comment thread RELEASES.md Resolved
Comment thread scripts/release/release.sh Resolved
Comment thread scripts/release/release.sh Resolved

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

All blocking findings verified against the script. The cleanup-on-error bug applies to both new modes (--dry-run and --finalize), the prior --non-interactive gap on gh release delete is still unfixed, the new push preflight uses a non-force probe while the real push is forced (breaking retries against existing release branches), and --dry-run + --finalize silently creates a release. These directly contradict the contracts documented in RELEASES.md and the script help.

🔴 4 blocking | 💬 2 nitpick(s)

1 additional finding(s) omitted (not in diff).

🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `scripts/release/release.sh`:
- [BLOCKING] scripts/release/release.sh:13-17: error() unconditionally calls cleanup(), violating the non-mutating contracts of --finalize and --dry-run
  error() (lines 13-17) calls cleanup() (lines 497-508) before exit. cleanup() performs `git checkout --quiet -- CHANGELOG.md`, `git checkout --quiet "${SOURCE_BRANCH}"`, `git branch --quiet -D "${RELEASE_BRANCH}"`, and `make clean`. Both new modes route failures through error():

  • --finalize (lines 526-540): RELEASES.md states it 'can be run from any checkout; only GitHub auth is required.' But the not-yet-merged check at line 531, the auth check inside validateFinalize at line 224, and the new preflightFinalize at line 265 all use error(). An operator who runs `release.sh --release=X.Y.Z --finalize` from an unrelated checkout while the PR is unmerged will have their CHANGELOG.md edits discarded, get switched off their current branch, lose any local branch coincidentally named release_X.Y.Z, and have `make clean` run in the wrong tree.

  • --dry-run (lines 545-561): the CLI help promises 'Restores the working tree on exit ... Safe to use as a pre-check.' The trap at line 547 only restores CHANGELOG.md. Any failure inside preflight (Docker, gh auth), validate (wrong branch, dirty tree, out-of-sync origin), or generateChangelog (docker run failure) still triggers full cleanup() → branch switch, branch delete, `make clean` on the user's tree.

  Fix: gate cleanup() inside error() so it only runs in the standard prep flow (e.g., skip cleanup when FINALIZE=yes or DRY_RUN=yes), or give the API-only and dry-run paths their own non-destructive bail-out helper.
- [BLOCKING] scripts/release/release.sh:518-545: --dry-run combined with --finalize silently creates a real release
  Mode flags are not mutually exclusive and are evaluated in order: FINALIZE at 526, DRY_RUN at 545, NO_WAIT at 588. If a caller passes `--dry-run --finalize` (easy with agents that assemble flags incrementally), the script takes the FINALIZE branch, verifies the PR is merged, and calls createReleaseIdempotent — actually creating the draft GitHub release despite --dry-run promising 'no remote, commit, push, PR, tag, or release action.' The same silent-precedence issue applies to `--no-wait --finalize` and `--dry-run --no-wait`. Reject contradictory combinations in parseArgs (or right after configureFinal) with a clear error, rather than executing whichever wins the ordering race.
- [BLOCKING] scripts/release/release.sh:374-381: deleteRelease still ignores NON_INTERACTIVE; --cleanup --no-wait can hang on stdin
  NON_INTERACTIVE is set directly via --non-interactive/--yes (line 141) and implied by --no-wait, --finalize, and --dry-run (lines 519-521), but no call site reads it. deleteRelease (lines 374-381) calls `gh release delete "v${NEW_PACKAGE_VERSION}"` on line 376 without `--yes`, which prompts for confirmation by default. Running `release.sh --release=X.Y.Z --cleanup --no-wait` therefore blocks waiting for stdin input, defeating the agent/CI flow the flag was added to support. Wire NON_INTERACTIVE into this call (`gh release delete --yes "v${NEW_PACKAGE_VERSION}"` when set) and audit any other interactive `gh` prompts the new modes can reach.
- [BLOCKING] scripts/release/release.sh:248-258: Push preflight uses a non-force dry-run probe; the real push is forced — breaks retries and --cleanup recovery
  The new preflight probe at line 249 is `git push --dry-run origin "HEAD:refs/heads/${RELEASE_BRANCH}"`, but the actual push at line 308 is `git push --force -u origin "${RELEASE_BRANCH}"`. When origin/release_<ver> already exists with divergent history (common after a prior failed attempt, since cleanup() and deleteRelease() only remove local branches and tags, not the remote release branch), the dry-run probe — issued from HEAD still on SOURCE_BRANCH — is rejected as non-fast-forward even though the real push would succeed via --force. In non-DRY_RUN mode this routes through error() at line 254, aborting the prep flow (and, per the cleanup finding above, running `make clean`). Mirror the real push semantics with `git push --dry-run --force ...`, or pre-delete the remote release branch in the --cleanup path.

Note: GitHub rejected inline comments for this detached older head after the PR advanced, so this exact-SHA review is posted body-only.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

Three carry-forward blocking issues remain unresolved: --dry-run --finalize still bypasses the dry-run guarantee, deleteRelease still lacks --yes for non-interactive cleanup, and the preflight push probe is non-force while the real push forces. A new blocker was introduced in the dry-run path: validate() fast-forwards the local branch via git merge --ff-only, mutating the working checkout despite the documented restore-on-exit contract. The nitpick about duplicate gh auth checks in finalize preflight still applies. The two prior FIXED items (error-path cleanup guard, NON_INTERACTIVE-before-debug ordering) verify clean.

🔴 4 blocking | 💬 1 nitpick(s)

1 additional finding(s) omitted (not in diff).

🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `scripts/release/release.sh`:
- [BLOCKING] scripts/release/release.sh:540-543: --dry-run --finalize silently creates a real draft release
  Mutual-exclusivity is only enforced between --no-wait and --finalize (lines 541-543). The FINALIZE branch (line 557) is evaluated before the DRY_RUN branch (line 576), so invoking `release.sh --release=... --dry-run --finalize` enters the FINALIZE block, validates the PR, and calls createReleaseIdempotent — which performs `gh release create --draft`. That breaks --dry-run's documented contract that 'no remote or commit actions are performed' (line 64). The cleanest fix is to reject any combination of mode flags, since --no-wait, --finalize, and --dry-run express distinct, non-overlapping intents.
- [BLOCKING] scripts/release/release.sh:216-220: --dry-run can fast-forward the caller's local branch
  The --dry-run path calls validate() (line 581), and validate() runs `git merge --ff-only origin/${SOURCE_BRANCH}` whenever local HEAD differs from origin (line 218). That mutates the caller's checkout — the local branch is silently advanced — while --dry-run is documented as a non-mutating pre-check that 'restores the working tree on exit' (lines 62-66). The dry-run trap at line 578 only restores CHANGELOG.md, so the branch position change persists. A dry-run should report the divergence instead of fixing it.
- [BLOCKING] scripts/release/release.sh:391-398: deleteRelease omits --yes, hanging non-interactive --cleanup paths
  NON_INTERACTIVE is implied by --no-wait, --finalize, and --dry-run (line 536-538), and the prep flow calls deleteRelease whenever --cleanup is set (line 600). However `gh release delete` at line 393 is invoked without --yes, so it prompts interactively for confirmation. Running `release.sh --cleanup --no-wait` therefore stalls on stdin in exactly the scenarios this PR is meant to enable. The git tag/remote-tag deletions below are already guarded with `|| true`, but the gh release delete is not.
- [BLOCKING] scripts/release/release.sh:263-275: Preflight push probe is non-force while real push is forced — breaks retries
  Preflight runs `git push --dry-run origin HEAD:refs/heads/${RELEASE_BRANCH}` (line 266, no --force) while the actual push at line 325 is `git push --force`. deleteRelease (line 391-398) does not remove the remote release_<ver> branch — it only deletes the tag — so the remote branch persists across retries. After a partial previous run, the preflight probe will fail with non-fast-forward, aborting before any real work even though the real force-push path is designed to overwrite that branch. This blocks legitimate retries and --cleanup-then-rerun recovery without diagnosing any real credential problem. The probe should mirror the real push's force semantics.

Comment thread scripts/release/release.sh Resolved
Comment thread scripts/release/release.sh Resolved
Comment thread scripts/release/release.sh Resolved
Comment on lines +278 to +286
# preflightFinalize is the lightweight preflight for --finalize mode.
# Finalize is API-only (no Docker, no git push); only gh auth is checked.
function preflightFinalize() {
debug "Running preflight checks (finalize mode)"
if ! gh auth status &>/dev/null; then
error "Not authenticated to GitHub; run 'gh auth login' first"
fi
debug "Preflight: gh auth OK"
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💬 Nitpick: preflightFinalize duplicates validateFinalize's gh auth check

preflightFinalize (lines 280-286) only checks gh auth status, and validateFinalize (lines 233-235) re-checks the same thing immediately after. validateFinalize already does the more meaningful gh repo view resolution check (line 241), so preflightFinalize adds no coverage. Fold the auth check into validateFinalize and drop preflightFinalize, or replace it with a check the validate step doesn't do (e.g. verify the source branch can be fetched before getPrState is called).

source: ['claude', 'codex']

Four blocking issues resolved:

1. Mode-flag mutual exclusivity extended to --dry-run: the previous guard
   only covered --no-wait/--finalize, so --dry-run --finalize would silently
   enter the FINALIZE branch and call createReleaseIdempotent — creating a
   real draft release despite --dry-run's documented no-mutation contract.
   Now all three mode flags are checked together; combining any two errors.

2. validate() no longer fast-forwards in --dry-run mode: git merge --ff-only
   would silently advance the caller's local branch even though --dry-run is
   documented as 'restores the working tree on exit'. Now an out-of-sync
   checkout is an immediate error in dry-run mode (must be sync'd before
   the dry-run, not auto-fixed by it).

3. Push-credential probe now mirrors the real force-push: the probe was
   git push --dry-run (no --force) while the real push at createReleasePR
   uses --force. After any partial previous run the remote release branch
   exists and the non-force probe fails, blocking legitimate retries.
   Changed to git push --dry-run --force to match the actual operation.

4. deleteRelease passes --yes in non-interactive mode: gh release delete
   without --yes blocks on a confirmation prompt, hanging agent/CI
   invocations that run with --cleanup --no-wait or --non-interactive.

Also: sanitize raw git push stderr before logging (avoids leaking embedded
https://token@host credentials from the remote URL in CI logs).

RELEASES.md: clarify --dry-run wording — "without touching any remote" was
factually wrong (auth checks and the push dry-run probe do contact remotes
read-only); changed to "without remote mutations".

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@lklimek

lklimek commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator Author

Bot-review pass — commit b744eca

Addressed all four thepastaclaw BLOCKING items from round 3, plus two medium coderabbitai findings. Resolved the 6 corresponding threads.

Fixed (commit b744eca)

# Severity Finding What changed
1 🔴 Blocking --dry-run --finalize silently creates a real draft release Extended the mutual-exclusivity guard to cover all three mode flags; combining any two now errors immediately with a clear message.
2 🔴 Blocking validate() fast-forwards the caller's local branch in --dry-run When DRY_RUN is set, divergence is now an immediate error ("sync before running --dry-run") instead of a silent git merge --ff-only.
3 🔴 Blocking Push-credential probe uses non-force; real push is --force — breaks retries Probe is now git push --dry-run --force, mirroring the real push so an existing remote release branch from a prior run doesn't produce a false-negative.
4 🔴 Blocking deleteRelease blocks on stdin in non-interactive mode gh release delete now receives --yes when NON_INTERACTIVE is set.
5 🟠 Major Raw git push stderr in error message can leak embedded credentials stderr is sanitized via sed to mask https://token@host URLs before logging.
6 🟡 Minor RELEASES.md claims --dry-run doesn't touch remotes at all Wording changed to "without remote mutations" (auth checks and the push dry-run probe do contact remotes read-only).

Not fixed — flagged for author (lklimek)

Finding Reason
💬 preflightFinalize duplicates validateFinalize's gh auth check Purely a refactoring question — both functions work correctly. Author to decide if they want to fold the auth check into validateFinalize and drop preflightFinalize.

CI

All checks were green before this commit; no logic changes in the Go codebase.

🤖 Co-authored by Claudius the Magnificent AI Agent

@lklimek
lklimek requested a review from thepastaclaw June 22, 2026 09:48
@lklimek

lklimek commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator Author

@thepastaclaw please re-review — all 4 blocking items from your last review are addressed in b744eca and CI is green (20/20).

🤖 Co-authored by Claudius the Magnificent AI Agent

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

Round 3 resolves the prior blocking issues. Only a low-confidence nit remains: preflightFinalize at lines 288-294 duplicates the gh auth status check that validateFinalize performs immediately afterward at lines 236-238, since they are called back-to-back at lines 576-577 in the FINALIZE path. Two Codex 'blocking' findings against node/node.go and version/version.go are false positives — those files are not modified by this PR (verified against origin/v1.6-dev: diff is limited to RELEASES.md and scripts/release/release.sh).

Reviewed commit: b744ecaf

💬 1 nitpick(s)

Verified findings

💬 Nitpick: preflightFinalize duplicates validateFinalize's gh auth check

scripts/release/release.sh (lines 286-294)

preflightFinalize only runs gh auth status, which validateFinalize re-runs at line 236 immediately afterward — and validateFinalize then performs the strictly stronger gh repo view resolution check at line 244. At lines 576-577 the two are called back-to-back, so preflightFinalize contributes no defensive coverage that validateFinalize wouldn't already catch one line later. Either fold the auth check entirely into validateFinalize and drop preflightFinalize, or repurpose it to verify something validateFinalize doesn't (e.g., that SOURCE_BRANCH can be fetched, since getPrState depends on remote branch state).

Repair note: the inline poster deduped this same finding against an existing thread and skipped creating a substantive top-level review; this body-only review records exact-SHA coverage without duplicating inline comments.

@lklimek
lklimek merged commit 9b7d726 into v1.6-dev Jun 22, 2026
17 checks passed
@lklimek
lklimek deleted the chore/release-script-agent-friendly branch June 22, 2026 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants