diff --git a/Cargo.toml b/Cargo.toml index cca2a5563..bfb8e925a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ resolver = "2" [workspace.package] edition = "2021" -version = "0.32.0" +version = "0.33.0" license = "Apache-2.0" authors = ["Databend Authors "] categories = ["database"] @@ -22,10 +22,10 @@ keywords = ["databend", "database", "rust"] repository = "https://github.com/databendlabs/bendsql" [workspace.dependencies] -databend-client = { path = "core", version = "0.32.0" } -databend-driver = { path = "driver", version = "0.32.0" } -databend-driver-core = { path = "sql", version = "0.32.0" } -databend-driver-macros = { path = "macros", version = "0.32.0" } +databend-client = { path = "core", version = "0.33.0" } +databend-driver = { path = "driver", version = "0.33.0" } +databend-driver-core = { path = "sql", version = "0.33.0" } +databend-driver-macros = { path = "macros", version = "0.33.0" } jsonb = { version = "0.5.5" } tokio-stream = "0.1" diff --git a/Makefile b/Makefile index d79bf69b0..08505c1ea 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: check build test integration +.PHONY: check build test integration bump-major bump-minor bump-patch default: build @@ -60,3 +60,12 @@ integration-bindings-python: integration-bindings-nodejs: make -C tests test-bindings-nodejs + +bump-major: + ./scripts/bump_version.py major + +bump-minor: + ./scripts/bump_version.py minor + +bump-patch: + ./scripts/bump_version.py patch diff --git a/bindings/nodejs/npm/darwin-arm64/package.json b/bindings/nodejs/npm/darwin-arm64/package.json index 64f67020a..fef0c092c 100644 --- a/bindings/nodejs/npm/darwin-arm64/package.json +++ b/bindings/nodejs/npm/darwin-arm64/package.json @@ -1,7 +1,7 @@ { "name": "@databend-driver/lib-darwin-arm64", "repository": "https://github.com/databendlabs/bendsql.git", - "version": "0.32.0", + "version": "0.33.0", "os": [ "darwin" ], diff --git a/bindings/nodejs/npm/darwin-x64/package.json b/bindings/nodejs/npm/darwin-x64/package.json index 3d49ebece..b6ce85a32 100644 --- a/bindings/nodejs/npm/darwin-x64/package.json +++ b/bindings/nodejs/npm/darwin-x64/package.json @@ -1,7 +1,7 @@ { "name": "@databend-driver/lib-darwin-x64", "repository": "https://github.com/databendlabs/bendsql.git", - "version": "0.32.0", + "version": "0.33.0", "os": [ "darwin" ], diff --git a/bindings/nodejs/npm/linux-arm64-gnu/package.json b/bindings/nodejs/npm/linux-arm64-gnu/package.json index 1ee626602..bf6cb1ba0 100644 --- a/bindings/nodejs/npm/linux-arm64-gnu/package.json +++ b/bindings/nodejs/npm/linux-arm64-gnu/package.json @@ -1,7 +1,7 @@ { "name": "@databend-driver/lib-linux-arm64-gnu", "repository": "https://github.com/databendlabs/bendsql.git", - "version": "0.32.0", + "version": "0.33.0", "os": [ "linux" ], diff --git a/bindings/nodejs/npm/linux-arm64-musl/package.json b/bindings/nodejs/npm/linux-arm64-musl/package.json index 84fee9995..f931e19b2 100644 --- a/bindings/nodejs/npm/linux-arm64-musl/package.json +++ b/bindings/nodejs/npm/linux-arm64-musl/package.json @@ -1,7 +1,7 @@ { "name": "@databend-driver/lib-linux-arm64-musl", "repository": "https://github.com/databendlabs/bendsql.git", - "version": "0.32.0", + "version": "0.33.0", "os": [ "linux" ], diff --git a/bindings/nodejs/npm/linux-x64-gnu/package.json b/bindings/nodejs/npm/linux-x64-gnu/package.json index c3b1fd66c..c89ac23a8 100644 --- a/bindings/nodejs/npm/linux-x64-gnu/package.json +++ b/bindings/nodejs/npm/linux-x64-gnu/package.json @@ -1,7 +1,7 @@ { "name": "@databend-driver/lib-linux-x64-gnu", "repository": "https://github.com/databendlabs/bendsql.git", - "version": "0.32.0", + "version": "0.33.0", "os": [ "linux" ], diff --git a/bindings/nodejs/npm/linux-x64-musl/package.json b/bindings/nodejs/npm/linux-x64-musl/package.json index fdf9755eb..7a3e640bb 100644 --- a/bindings/nodejs/npm/linux-x64-musl/package.json +++ b/bindings/nodejs/npm/linux-x64-musl/package.json @@ -1,7 +1,7 @@ { "name": "@databend-driver/lib-linux-x64-musl", "repository": "https://github.com/databendlabs/bendsql.git", - "version": "0.32.0", + "version": "0.33.0", "os": [ "linux" ], diff --git a/bindings/nodejs/npm/win32-arm64-msvc/package.json b/bindings/nodejs/npm/win32-arm64-msvc/package.json index 840dc0df6..fbe92c551 100644 --- a/bindings/nodejs/npm/win32-arm64-msvc/package.json +++ b/bindings/nodejs/npm/win32-arm64-msvc/package.json @@ -1,7 +1,7 @@ { "name": "@databend-driver/lib-win32-arm64-msvc", "repository": "https://github.com/databendlabs/bendsql.git", - "version": "0.32.0", + "version": "0.33.0", "os": [ "win32" ], diff --git a/bindings/nodejs/npm/win32-x64-msvc/package.json b/bindings/nodejs/npm/win32-x64-msvc/package.json index 69b977939..13c863d5a 100644 --- a/bindings/nodejs/npm/win32-x64-msvc/package.json +++ b/bindings/nodejs/npm/win32-x64-msvc/package.json @@ -1,7 +1,7 @@ { "name": "@databend-driver/lib-win32-x64-msvc", "repository": "https://github.com/databendlabs/bendsql.git", - "version": "0.32.0", + "version": "0.33.0", "os": [ "win32" ], diff --git a/bindings/nodejs/package.json b/bindings/nodejs/package.json index 59ef0383d..b865f2778 100644 --- a/bindings/nodejs/package.json +++ b/bindings/nodejs/package.json @@ -1,7 +1,7 @@ { "name": "databend-driver", "author": "Databend Authors ", - "version": "0.32.0", + "version": "0.33.0", "license": "Apache-2.0", "main": "index.js", "types": "index.d.ts", diff --git a/scripts/bump.sh b/scripts/bump.sh deleted file mode 100755 index 537cf4fe7..000000000 --- a/scripts/bump.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash - -# Copyright 2021 Datafuse Labs -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -e - -VERSION=$1 - -if [ -z "$VERSION" ]; then - echo "Usage: bump.sh " - exit 1 -fi - -echo "Bumping version to $VERSION" - -git status -git checkout main -git fetch upstream -git rebase upstream/main -git checkout -b "bump-$VERSION" - -if [[ "$OSTYPE" == "darwin"* ]]; then - sed -ri '' "s/^version = \".*\"/version = \"$VERSION\"/g" Cargo.toml - sed -ri '' "s/^databend-(.*)version = \".*\"/databend-\1version = \"$VERSION\"/g" Cargo.toml - sed -i '' "s/\"version\": \".*\"/\"version\": \"$VERSION\"/g" bindings/nodejs/package.json - sed -i '' "s/\"version\": \".*\"/\"version\": \"$VERSION\"/g" bindings/nodejs/npm/*/package.json -else - sed -ri "s/^version = \".*\"/version = \"$VERSION\"/g" Cargo.toml - sed -ri "s/^databend-(.*)version = \".*\"/databend-\\1version = \"$VERSION\"/g" Cargo.toml - sed -i "s/\"version\": \".*\"/\"version\": \"$VERSION\"/g" bindings/nodejs/package.json - sed -i "s/\"version\": \".*\"/\"version\": \"$VERSION\"/g" bindings/nodejs/npm/*/package.json -fi - -git status -git add Cargo.toml bindings/nodejs/package.json bindings/nodejs/npm/*/package.json -git commit -m "chore: bump version to $VERSION" diff --git a/scripts/bump_version.py b/scripts/bump_version.py new file mode 100755 index 000000000..816082f26 --- /dev/null +++ b/scripts/bump_version.py @@ -0,0 +1,140 @@ +#!/usr/bin/env python3 + +# Copyright 2021 Datafuse Labs +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import argparse +import json +import pathlib +import re +import subprocess +import sys + + +ROOT = pathlib.Path(__file__).resolve().parents[1] +CARGO_TOML = ROOT / "Cargo.toml" +NODE_PACKAGE = ROOT / "bindings" / "nodejs" / "package.json" +NODE_NPM_DIR = ROOT / "bindings" / "nodejs" / "npm" + + +def ensure_clean_git_state() -> None: + result = subprocess.run( + ["git", "status", "--porcelain"], + capture_output=True, + text=True, + cwd=ROOT, + check=True, + ) + if result.stdout.strip(): + sys.exit( + "Working tree has uncommitted changes. Please clean up before bumping." + ) + + +def read_current_version() -> tuple[str, list[str], int]: + lines = CARGO_TOML.read_text().splitlines() + in_workspace_pkg = False + for idx, line in enumerate(lines): + stripped = line.strip() + if stripped.startswith("[") and stripped != "[workspace.package]": + in_workspace_pkg = False + if stripped == "[workspace.package]": + in_workspace_pkg = True + continue + if in_workspace_pkg and stripped.startswith("version"): + match = re.search(r'"([^"]+)"', line) + if not match: + break + return match.group(1), lines, idx + raise SystemExit("Unable to find workspace package version in Cargo.toml") + + +def compute_new_version(version: str, bump: str) -> str: + parts = version.split(".") + if len(parts) != 3: + raise SystemExit(f"Unsupported version format: {version}") + major, minor, patch = (int(part) for part in parts) + if bump == "major": + major += 1 + minor = 0 + patch = 0 + elif bump == "minor": + minor += 1 + patch = 0 + elif bump == "patch": + patch += 1 + else: + raise SystemExit(f"Unknown bump type: {bump}") + return f"{major}.{minor}.{patch}" + + +def update_cargo_toml(lines: list[str], version_index: int, new_version: str) -> None: + target_line = lines[version_index] + lines[version_index] = re.sub(r'"[^"]+"', f'"{new_version}"', target_line, count=1) + for idx, line in enumerate(lines): + stripped = line.strip() + if stripped.startswith("databend-") and "version" in line: + lines[idx] = re.sub( + r'version\s*=\s*"[^"]+"', f'version = "{new_version}"', line, count=1 + ) + CARGO_TOML.write_text("\n".join(lines) + "\n") + + +def update_package_json(path: pathlib.Path, new_version: str) -> None: + data = json.loads(path.read_text()) + data["version"] = new_version + path.write_text(json.dumps(data, indent=2) + "\n") + + +def update_node_packages(new_version: str) -> list[pathlib.Path]: + updated = [NODE_PACKAGE] + update_package_json(NODE_PACKAGE, new_version) + for package_json in sorted(NODE_NPM_DIR.glob("*/package.json")): + update_package_json(package_json, new_version) + updated.append(package_json) + return updated + + +def create_commit(new_version: str, extra_files: list[pathlib.Path]) -> None: + files = [CARGO_TOML, *extra_files] + subprocess.run( + ["git", "add", *[str(p.relative_to(ROOT)) for p in files]], check=True, cwd=ROOT + ) + subprocess.run( + ["git", "commit", "-m", f"chore: bump version to {new_version}"], + check=True, + cwd=ROOT, + ) + + +def main() -> None: + parser = argparse.ArgumentParser(description="Bump BendSQL workspace version") + parser.add_argument( + "bump", + choices=["major", "minor", "patch"], + help="Which part of the semver to increment", + ) + args = parser.parse_args() + + ensure_clean_git_state() + current_version, lines, version_index = read_current_version() + new_version = compute_new_version(current_version, args.bump) + update_cargo_toml(lines, version_index, new_version) + updated_json = update_node_packages(new_version) + create_commit(new_version, updated_json) + print(f"Bumped version: {current_version} -> {new_version}") + + +if __name__ == "__main__": + main()