Skip to content

Commit edf6af4

Browse files
Taskfile: task release auto-creates the release branch (#177)
Previously the task refused to run on main and told the user to `git checkout -b release/... && task release`. Friction for a step with one obvious value (the date). New behavior: from main, `task release -- patch` pulls latest main, creates `release/<timestamp>`, bumps, commits, pushes, opens PR. Refuses to run NOT on main (inverted), and refuses if local main has unpushed commits (weird state worth surfacing). RUNBOOK updated.
1 parent 2f1face commit edf6af4

2 files changed

Lines changed: 25 additions & 11 deletions

File tree

RUNBOOK.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ Decision guide for the `/sdk` pipeline. Read this, then go.
44

55
## Releasing
66

7-
1. **From a fresh branch off main, run `task release -- patch`** (or `minor` / `major`). This bumps both `browser-use-node/package.json` and `browser-use-python/pyproject.toml` to the next version, commits as `release: v<NEW_VERSION>`, pushes the branch, and opens a PR.
7+
1. **From `main`, run `task release -- patch`** (or `minor` / `major`). This pulls latest main, creates a fresh `release/<timestamp>` branch off it, bumps both `browser-use-node/package.json` and `browser-use-python/pyproject.toml`, commits as `release: v<NEW_VERSION>`, pushes the branch, and opens a PR.
88

99
Manual alternative (if you don't want the helper):
1010

1111
```bash
12-
git checkout -b release/$(date +%Y%m%d) main
12+
git checkout main && git pull --ff-only origin main
13+
git checkout -b release/$(date +%Y%m%d-%H%M%S)
1314
task version:bump -- patch
1415

1516
# Read the new version after the bump, then use it in commit + PR.

Taskfile.yml

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -199,23 +199,36 @@ tasks:
199199
exit 1
200200
fi
201201
202-
# Refuse to run on main directly — releases must go through a PR for
203-
# the auto-detector to fire on merge.
202+
# The task auto-creates the release branch from main, so it must be
203+
# run FROM main. Refuse otherwise — running from a feature branch
204+
# would surprise the user with a branch named off a non-main tip.
204205
CURRENT_BRANCH="$(git rev-parse --abbrev-ref HEAD)"
205-
if [ "$CURRENT_BRANCH" = "main" ]; then
206-
echo "ERROR: refusing to run on main. Releases go through a PR; the auto-detector fires on merge." >&2
207-
echo "Run from a fresh branch off main, e.g.:" >&2
208-
echo " git checkout -b release/\$(date +%Y%m%d) main && task release -- $BUMP" >&2
206+
if [ "$CURRENT_BRANCH" != "main" ]; then
207+
echo "ERROR: refusing to run. \`task release\` auto-creates a release branch off main, so it must be started from main." >&2
208+
echo "Currently on: $CURRENT_BRANCH" >&2
209+
echo "Switch first:" >&2
210+
echo " git checkout main" >&2
209211
exit 1
210212
fi
211213
212-
# Make sure we're up-to-date with main so the bump diff is clean.
214+
# Fast-forward main to origin/main so the new branch is based on the
215+
# latest published main, not whatever stale state we have locally.
216+
# --ff-only fails if local main has unpushed commits, which would be
217+
# weird — bail loud so the user reconciles.
213218
git fetch origin main --quiet
214219
if ! git merge-base --is-ancestor origin/main HEAD; then
215-
echo "ERROR: branch is behind origin/main. Rebase first:" >&2
216-
echo " git rebase origin/main" >&2
220+
echo "ERROR: local main has commits not on origin/main. Reconcile before releasing." >&2
221+
echo " git log origin/main..HEAD --oneline" >&2
217222
exit 1
218223
fi
224+
git pull --ff-only origin main --quiet
225+
226+
# Create the release branch. Date+time keeps it unique across
227+
# multiple releases the same day; the branch auto-deletes on PR merge
228+
# (squash + delete-on-merge), so the branch list stays clean.
229+
NEW_BRANCH="release/$(date +%Y%m%d-%H%M%S)"
230+
git checkout -b "$NEW_BRANCH"
231+
echo "::notice::Created release branch $NEW_BRANCH from main."
219232
- task: "version:bump"
220233
vars: { CLI_ARGS: '{{.CLI_ARGS | default "patch"}}' }
221234
- cmd: |

0 commit comments

Comments
 (0)