Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,32 @@ hotdata tables list <workspace_id> --connection-id <connection_id> [--format tab
hotdata query "<sql>" --workspace-id <workspace_id> [--connection <connection_id>] [--format table|json|csv]
```

## Releasing

Releases use a two-phase workflow wrapping [`cargo-release`](https://github.com/crate-ci/cargo-release).

**Phase 1 — prepare**

```sh
scripts/release.sh prepare <version>
# e.g. scripts/release.sh prepare 0.2.0
```

This will:
1. Create a `release/<version>` branch
2. Bump the version in `Cargo.toml`, update `CHANGELOG.md`, and push the branch
3. Open a GitHub pull request and launch it in the browser

Squash and merge the PR into `main` when ready.

**Phase 2 — finish**

```sh
scripts/release.sh finish
```

Run this from any branch after the PR is merged. It will switch to `main`, pull the latest, tag the release, and trigger the dist workflow.

## Configuration

Config is stored at `~/.hotdata/config.yml` keyed by profile (default: `default`).
Expand Down
84 changes: 84 additions & 0 deletions scripts/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/usr/bin/env bash
# release.sh — two-phase release wrapper around cargo-release
#
# Usage:
# scripts/release.sh prepare <version> # steps 0-2: branch, bump, push PR
# scripts/release.sh finish # step 4: tag, publish, trigger dist

set -euo pipefail

COMMAND="${1:-}"
VERSION="${2:-}"

usage() {
echo "Usage:"
echo " scripts/release.sh prepare <version> # create release branch and open PR"
echo " scripts/release.sh finish # tag and publish from main"
exit 1
}

require_clean_tree() {
if ! git diff --quiet || ! git diff --cached --quiet; then
echo "error: working tree is not clean. Commit or stash your changes first."
exit 1
fi
}

case "$COMMAND" in
prepare)
if [ -z "$VERSION" ]; then
echo "error: version required (e.g. scripts/release.sh prepare 0.2.0)"
usage
fi

BRANCH="release/$VERSION"

# 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"


# step 2: bump versions, commit, push branch
echo ""
echo "→ Running cargo release (no publish, no tag)..."
cargo release --no-publish --no-tag --allow-branch="$BRANCH" "$VERSION"

echo ""
echo "→ Opening pull request..."
PR_URL=$(gh pr create \
--title "chore: Release hotdata-cli version $VERSION" \
--base main \
--head "$BRANCH")

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

echo ""
echo "Next steps:"
echo " 1. Review and merge the PR (use 'Squash and merge')"
echo " 2. Run: scripts/release.sh finish"
;;

finish)
require_clean_tree

CURRENT_BRANCH="$(git rev-parse --abbrev-ref HEAD)"
if [ "$CURRENT_BRANCH" != "main" ]; then
echo "→ Switching to main..."
git checkout main
fi

echo "→ Pulling latest main..."
git pull

echo ""
echo "→ Running cargo release (tagging release)..."
cargo release

echo ""
echo "✓ Release complete. Tag pushed and dist workflow triggered."
;;

*)
usage
;;
esac
Loading