Skip to content
Merged
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
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ resolver = "2"

[workspace.package]
edition = "2021"
version = "0.32.0"
version = "0.33.0"
license = "Apache-2.0"
authors = ["Databend Authors <[email protected]>"]
categories = ["database"]
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"
Expand Down
11 changes: 10 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: check build test integration
.PHONY: check build test integration bump-major bump-minor bump-patch

default: build

Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion bindings/nodejs/npm/darwin-arm64/package.json
Original file line number Diff line number Diff line change
@@ -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"
],
Expand Down
2 changes: 1 addition & 1 deletion bindings/nodejs/npm/darwin-x64/package.json
Original file line number Diff line number Diff line change
@@ -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"
],
Expand Down
2 changes: 1 addition & 1 deletion bindings/nodejs/npm/linux-arm64-gnu/package.json
Original file line number Diff line number Diff line change
@@ -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"
],
Expand Down
2 changes: 1 addition & 1 deletion bindings/nodejs/npm/linux-arm64-musl/package.json
Original file line number Diff line number Diff line change
@@ -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"
],
Expand Down
2 changes: 1 addition & 1 deletion bindings/nodejs/npm/linux-x64-gnu/package.json
Original file line number Diff line number Diff line change
@@ -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"
],
Expand Down
2 changes: 1 addition & 1 deletion bindings/nodejs/npm/linux-x64-musl/package.json
Original file line number Diff line number Diff line change
@@ -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"
],
Expand Down
2 changes: 1 addition & 1 deletion bindings/nodejs/npm/win32-arm64-msvc/package.json
Original file line number Diff line number Diff line change
@@ -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"
],
Expand Down
2 changes: 1 addition & 1 deletion bindings/nodejs/npm/win32-x64-msvc/package.json
Original file line number Diff line number Diff line change
@@ -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"
],
Expand Down
2 changes: 1 addition & 1 deletion bindings/nodejs/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "databend-driver",
"author": "Databend Authors <[email protected]>",
"version": "0.32.0",
"version": "0.33.0",
"license": "Apache-2.0",
"main": "index.js",
"types": "index.d.ts",
Expand Down
48 changes: 0 additions & 48 deletions scripts/bump.sh

This file was deleted.

140 changes: 140 additions & 0 deletions scripts/bump_version.py
Original file line number Diff line number Diff line change
@@ -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()
Loading