Skip to content

Release script: one command from version to pushed tag - #165

Merged
JacobStephens2 merged 3 commits into
mainfrom
issue-156
Sep 30, 2026
Merged

JacobStephens2 merged 3 commits into
mainfrom
issue-156

Conversation

@JacobStephens2

Copy link
Copy Markdown
Owner

Summary

scripts/release.sh <version> goes from a version number to a pushed v<version> tag, which starts the existing dist release workflow.

release.sh 0.4.0
  fetch origin/main → temporary detached worktree   # maintainer's checkout untouched
  bump version in Cargo.toml + Cargo.lock only → commit → push release-0.4.0
  body = "## Summary" + <!-- release-summary:start --> generated notes <!-- release-summary:end -->
         + "## Version diff" (```diff written by the script)
  gh pr create → "release: opened <url>"
  poll actions/runs?head_sha=<head> until every workflow run completed → "release: waiting for CI on <url>"
    any not success/skipped/neutral → "CI failed on <url> (<names>) …" exit 1, PR left open, no tag
  gh pr merge --merge --match-head-commit <head> → "release: merged <url> as <sha>"
  git push origin <merge>:refs/tags/v0.4.0 → "release: tagged v0.4.0 on <sha> and pushed the tag"

It waits on workflow runs rather than check runs because release.yml also runs on pull_request, and its build jobs only appear after plan finishes. The generated notes cover the PRs merged since the last v* tag (previous_tag_name), with target_commitish set to the origin/main commit.

 tests/fakes/gh
+  gh api repos/<repo>/releases/generate-notes   # notes from merged PRs' mergeCommit reachability
+  gh api repos/<repo>/actions/runs?head_sha=…   # served from the sha's check runs
+  a merged PR records mergeCommit; {owner}/{repo} is accepted as the fake's repo
 tests/release.rs                                # black box vs a bare origin, user git config kept out
 README.md  ## Releasing                         # rewritten around the one command

Evidence

  • Before: there was no release script. Releasing was the three manual README steps.
    After: cargo test --test release passes 6 tests:

    • full release: the diff is only version in both files; the merge commit's parents are (old main, bump head); v0.2.0 on origin points at that merge commit
    • the PR body's marked summary holds the notes since v0.1.0 (and not the PR from before the tag), followed by the version diff
    • progress lines appear on stderr in order and stdout stays empty
    • a red check exits non-zero, leaves the PR OPEN, doesn't move main and pushes no tag
    • the maintainer's wip branch, local edits, untracked files, unpushed commit, branch list and worktree list are all unchanged, and none of them leak into the release
    • a failure to generate the notes stops the script before any PR is opened
  • The full cargo test, cargo clippy --all-targets -D warnings and shellcheck scripts/release.sh are clean.

  • Real stderr from the test run:

    release: bumping the version to 0.2.0 on release-0.2.0 from main at c6d618f
    release: opened https://github.com/JacobStephens2/thirdshift/pull/3
    release: waiting for CI on https://github.com/JacobStephens2/thirdshift/pull/3
    release: merged https://github.com/JacobStephens2/thirdshift/pull/3 as dd818b7
    release: tagged v0.2.0 on dd818b7 and pushed the tag
    

Unaddressed findings

Spec

  • RELEASE_POLL_SECONDS is an extra knob. It is kept as the test seam for the poll interval and documented in the script header. A maintainer never needs to set it.
  • previous_tag_name comes from local tags (git describe). Fetching main auto-follows tags, so local tags normally mirror origin. Fetching origin's tags into the maintainer's repo risks clobbering their local tags. The refusals ticket is a better place to revisit this.
  • {owner}/{repo} is ambiguous in a clone with several remotes and no gh repo set-default. This clone has a single origin. Deriving GH_REPO from the origin URL would need a GitHub-shaped origin in the tests. Left for when that case comes up.
  • The script could read the merge commit from gh pr view --json mergeCommit instead of git. The reviewer marked this "not a bug". Finding the merge on origin/main whose second parent is the head is exact, and it only reads from git.

Standards

  • Marker comments are speculative. The ticket asks for "the marker that the later agent summary (Release script: agent-written summary in the bump PR #159) and the Release page step will use", so they stay.
  • The fake's jq expression is coupled to the script's. That is deliberate. The fake already matches exact --jq strings so an unexpected call fails loudly.
  • isolated()/git() duplicate the helpers in site_deploy.rs and support/mod.rs. This follows the existing per-file prior art. The name isolated stays because, unlike without_user_git_config, it also sets the git identity.
  • The setup (new → ci_reports(GREEN) → run) repeats across tests. The repeated Arrange step keeps each test readable on its own. The duplicated headRefOid lookup was extracted into pr_head.

Merge Danger

Door: two-way

This only adds a maintainer script, a test and extensions to the fake. Nothing ships in the binary, because the crate's include leaves scripts/ out. Running the script is one-way: the pushed tag publishes to crates.io. Merging this PR runs nothing.

Blast Radius: tooling

The fake gh changes are additive. The {owner}/{repo} acceptance and the shared -f parsing touch paths the existing tests use, and the full suite passes.

Closes #156

🤖 Generated with Claude Code

JacobStephens2 and others added 3 commits September 30, 2026 00:39
scripts/release.sh <version> bumps the version on origin/main in a
temporary worktree, opens the release-<version> PR with GitHub's
generated notes in a marked summary section and the version diff, waits
for its checks, merges it with a merge commit, and tags and pushes
v<version> on that merge commit. Failing checks leave the PR open.

The fake gh gains the generate-notes API, a merged PR's merge commit, a
one-line-per-run form of the check-runs endpoint and gh's {owner}/{repo}
placeholder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The dist release workflow also runs on pull requests, and its build jobs
only appear once its plan job finishes, so a commit's check runs can all
be complete before CI is. A workflow run completes only with all its
jobs, so the script now waits on those.

With inherit_errexit, a failing gh call inside a command substitution,
such as generating the notes, stops the script instead of opening the PR
with an empty summary. The fake gh shares its -f parsing and treats
{owner}/{repo} in check_repo.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@JacobStephens2
JacobStephens2 merged commit fe464be into main Sep 30, 2026
13 checks passed
@JacobStephens2
JacobStephens2 deleted the issue-156 branch September 30, 2026 01:02
@JacobStephens2 JacobStephens2 mentioned this pull request Sep 30, 2026
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.

Release script: one command from version to pushed tag

1 participant