-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathTaskfile.yml
More file actions
171 lines (149 loc) Β· 6.68 KB
/
Copy pathTaskfile.yml
File metadata and controls
171 lines (149 loc) Β· 6.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
version: "3"
tasks:
generate:
desc: "Regenerate CDP types from protocol definitions"
cmds:
- uv run python -m cdp_use.generator
build:
desc: "Build the distribution package"
cmds:
- uv build
install:
desc: "Install package in development mode"
cmds:
- uv pip install -e .
lint:
desc: "Run ruff linter"
cmds:
- uv run ruff check cdp_use/ --statistics
format:
desc: "Format code with ruff"
cmds:
- uv run ruff format cdp_use/
format-json:
desc: "Format JSON protocol files"
cmds:
- |
for file in cdp_use/custom_protocols/*.json; do
[ -f "$file" ] || continue
python3 -m json.tool "$file" "$file.tmp" && mv "$file.tmp" "$file"
done
example:
desc: "Run the simple example"
cmds:
- uv run python simple.py
clean:
desc: "Clean generated files and build artifacts"
cmds:
- rm -rf dist/ build/ *.egg-info
- find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
# ββ Version Management ββββββββββββββββββββββββββββββββββββββββ
version:
desc: Show current version
cmds:
- echo "cdp-use:" $(uv run python -c "import tomllib; print(tomllib.load(open('pyproject.toml','rb'))['project']['version'])")
version:bump:
desc: "Bump version (usage: task version:bump -- patch|minor|major)"
cmds:
- cmd: |
set -euo pipefail
BUMP="{{.CLI_ARGS}}"
if [ -z "$BUMP" ]; then BUMP="patch"; fi
if [ "$BUMP" != "patch" ] && [ "$BUMP" != "minor" ] && [ "$BUMP" != "major" ]; then
echo "ERROR: invalid bump '$BUMP'. Use patch, minor, or major." >&2
exit 1
fi
NEW_VERSION=$(uv run python -c "
import tomllib
v = tomllib.load(open('pyproject.toml','rb'))['project']['version']
parts = [int(x) for x in v.split('.')]
if '$BUMP' == 'major': parts[0]+=1; parts[1]=0; parts[2]=0
elif '$BUMP' == 'minor': parts[1]+=1; parts[2]=0
else: parts[2]+=1
print('.'.join(str(p) for p in parts))
")
uv run python -c "
import re, pathlib
p = pathlib.Path('pyproject.toml')
p.write_text(re.sub(r'^version = \".*\"', f'version = \"${NEW_VERSION}\"', p.read_text(), count=1, flags=re.MULTILINE))
"
echo "cdp-use version bumped to ${NEW_VERSION}"
- task: version
release:
desc: "Cut a release: bump version, commit, push branch, open PR (usage: task release -- patch|minor|major)"
cmds:
- cmd: |
set -euo pipefail
BUMP="{{.CLI_ARGS}}"
if [ -z "$BUMP" ]; then BUMP="patch"; fi
if [ "$BUMP" != "patch" ] && [ "$BUMP" != "minor" ] && [ "$BUMP" != "major" ]; then
echo "ERROR: invalid bump '$BUMP'. Use patch, minor, or major." >&2
exit 1
fi
# Refuse to run on a dirty tree β too easy to ship unrelated WIP.
if ! git diff --quiet || ! git diff --cached --quiet; then
echo "ERROR: working tree is dirty. Commit or stash before releasing." >&2
git status --short >&2
exit 1
fi
# The task auto-creates the release branch from main, so it must be
# run FROM main. Refuse otherwise β running from a feature branch
# would surprise the user with a branch named off a non-main tip.
CURRENT_BRANCH="$(git rev-parse --abbrev-ref HEAD)"
if [ "$CURRENT_BRANCH" != "main" ]; then
echo "ERROR: refusing to run. \`task release\` auto-creates a release branch off main, so it must be started from main." >&2
echo "Currently on: $CURRENT_BRANCH" >&2
echo "Switch first:" >&2
echo " git checkout main" >&2
exit 1
fi
# Fast-forward main to origin/main so the new branch is based on the
# latest published main, not whatever stale state we have locally.
# --ff-only fails if local main has unpushed commits, which would be
# weird β bail loud so the user reconciles.
git fetch origin main --quiet
if ! git merge-base --is-ancestor origin/main HEAD; then
echo "ERROR: local main has commits not on origin/main. Reconcile before releasing." >&2
echo " git log origin/main..HEAD --oneline" >&2
exit 1
fi
git pull --ff-only origin main --quiet
# Create the release branch. Date+time keeps it unique across
# multiple releases the same day; the branch auto-deletes on PR merge
# (squash + delete-on-merge), so the branch list stays clean.
NEW_BRANCH="release/$(date +%Y%m%d-%H%M%S)"
git checkout -b "$NEW_BRANCH"
echo "::notice::Created release branch $NEW_BRANCH from main."
- task: "version:bump"
vars: { CLI_ARGS: '{{.CLI_ARGS | default "patch"}}' }
- cmd: |
set -euo pipefail
BUMP="{{.CLI_ARGS}}"
if [ -z "$BUMP" ]; then BUMP="patch"; fi
NEW_VERSION="$(uv run python -c "import tomllib; print(tomllib.load(open('pyproject.toml','rb'))['project']['version'])")"
echo
echo "Releasing v${NEW_VERSION}."
# Stage the manifest update that version:bump touched.
git add pyproject.toml
# Commit. Conventional-ish message so it's obvious in main's history.
git commit -m "release: v${NEW_VERSION}" -m "Bumps pyproject.toml. Merging this PR will trigger auto-release-on-version-bump β publish.yml (gated by the release env)."
# Push the branch. -u so future pushes work without args.
BRANCH="$(git rev-parse --abbrev-ref HEAD)"
git push -u origin "$BRANCH"
# Open the PR. If gh is logged in, this Just Works; otherwise prints
# the manual fallback URL.
if command -v gh >/dev/null 2>&1; then
gh pr create \
--repo browser-use/cdp-use \
--base main \
--head "$BRANCH" \
--title "release: v${NEW_VERSION}" \
--body "Bumps pyproject.toml to v${NEW_VERSION}.
Merging this PR triggers \`auto-release-on-version-bump\` β \`publish.yml\` (gated by the \`release\` env, requires a non-author approver, OIDC publish to PyPI).
Generated by \`task release -- $BUMP\`."
else
echo "gh CLI not found. Push succeeded; open the PR manually:"
echo " https://github.com/browser-use/cdp-use/compare/main...$BRANCH?expand=1"
fi
echo
echo "Done. Merge the PR to trigger the release."