Skip to content

Add release script wrapping cargo release#8

Merged
pthurlow merged 3 commits intomainfrom
fix/release-script
Mar 23, 2026
Merged

Add release script wrapping cargo release#8
pthurlow merged 3 commits intomainfrom
fix/release-script

Conversation

@pthurlow
Copy link
Collaborator

No description provided.


echo ""
echo "✓ PR created: $PR_URL"
open "$PR_URL"
Copy link
Contributor

Choose a reason for hiding this comment

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

open is macOS-only. With set -euo pipefail, this will cause the script to error-exit on Linux after the PR is already created — leaving the user with a confusing failure despite the PR succeeding.

Use a cross-platform helper:

Suggested change
open "$PR_URL"
if command -v xdg-open &>/dev/null; then
xdg-open "$PR_URL"
elif command -v open &>/dev/null; then
open "$PR_URL"
fi


# step 0: create release branch
echo "→ Creating branch $BRANCH"
git checkout -b "$BRANCH"
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider calling require_clean_tree before checking out the new branch. cargo release will modify Cargo.toml/CHANGELOG.md, so starting from a dirty tree can produce confusing diffs or cause cargo-release to abort mid-run.

Suggested change
git checkout -b "$BRANCH"
require_clean_tree
git checkout -b "$BRANCH"

Copy link
Contributor

@claude claude bot left a comment

Choose a reason for hiding this comment

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

Review

Issues

  • scripts/release.sh:54open "$PR_URL" is macOS-only. With set -euo pipefail, this causes the script to error-exit on Linux after the PR has already been created, leaving the user with a misleading failure. Fix: use a cross-platform xdg-open/open fallback (see inline comment).

  • scripts/release.sh:38prepare is missing a require_clean_tree call before modifying the repo. finish has this guard but prepare doesn't, even though it runs cargo release which edits Cargo.toml and CHANGELOG.md. A dirty tree risks confusing diffs or an unexpected mid-run abort from cargo-release.

Action Required

  1. Fix open "$PR_URL" to work cross-platform (or wrap in a best-effort with || true at minimum to avoid failing after a successful PR creation).
  2. Add require_clean_tree at the top of the prepare branch before git checkout -b.

let reader = pb.wrap_read(f);

let id = do_upload(client, api_key, workspace_id, api_url, ft.content_type, reader, pb);
let id = do_upload(client, api_key, workspace_id, api_url, ft.content_type, reader, pb, Some(file_size));
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: file_size defaults to 0 when metadata() fails (line 196). Before this PR that only affected the progress bar display; now it causes Content-Length: 0 to be sent to the server when the fallback kicks in, which is incorrect.

Consider computing the optional length separately so metadata failure means "omit the header" rather than "send 0":

Suggested change
let id = do_upload(client, api_key, workspace_id, api_url, ft.content_type, reader, pb, Some(file_size));
let content_length = f.metadata().ok().map(|m| m.len());
let file_size = content_length.unwrap_or(0);
let pb = make_progress_bar(file_size);
let reader = pb.wrap_read(f);
let id = do_upload(client, api_key, workspace_id, api_url, ft.content_type, reader, pb, content_length);

Non-blocking — metadata failure on an already-opened file is rare in practice.

@pthurlow pthurlow merged commit 0fa05b2 into main Mar 23, 2026
7 checks passed
@pthurlow pthurlow deleted the fix/release-script branch March 23, 2026 16:49
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.

1 participant