Files
lancedb/ci/tests/test_bump_version.sh
T
wangshun a0e65400a9 fix(java): keep Maven coordinates in sync with release tags (#5151)
Fixes #4937

## Summary

The `v0.42.0-beta.21` release commit retained `0.42.0-beta.20` in both
Java POMs, so its Maven build produced coordinates for the previous
beta. The release bump used a Maven version hook whose final shell
commands could return success after Maven failed, allowing the tag to be
created with stale coordinates. [Issue
#4937](https://github.com/lancedb/lancedb/issues/4937)

Declare both Maven version fields in the shared version-bump
configuration and align the checked-in POMs with the current release
version. Preview and stable release bumps now apply the same version to
the parent POM and the core module's parent reference before tagging.
Package names, dependencies, and publication destinations are preserved.

## Verification

Tests: `/bin/sh -c 'PATH=/tmp/osscout-release-venv/bin:$PATH bash
ci/tests/test_bump_version.sh'`.
Result: PATH=/tmp/osscout-release-venv/bin:$PATH bash
ci/tests/test_bump_version.sh — base exit 1 with the tag/POM mismatch,
patched exit 0 with both preview and stable cases passing.
Result: python -m unittest discover -s ci/tests -v — base, 35 passed.
Result: /tmp/osscout-release-venv/bin/python -m unittest discover -s
ci/tests -v — patched, 35 passed.
Result: bash ci/tests/test_cli_installer.sh — passed.
Result: cd java && ./mvnw --batch-mode test -pl lancedb-core — base, 37
passed on JDK 25.
Result: cd java && JAVA_HOME=/usr/lib/jvm/temurin-17-jdk-amd64 ./mvnw
--batch-mode -Dspotless.skip=true clean test -pl lancedb-core — patched,
37 passed. Surefire XML reports are in
java/lancedb-core/target/surefire-reports/.
Result: osscout_base_work=$(mktemp -d) && git archive HEAD java | tar
-xf - -C "$osscout_base_work" && cd "$osscout_base_work/java" &&
JAVA_HOME=/tmp/osscout-jdk8 ./mvnw --batch-mode -DskipTests
-Dspotless.skip=true clean deploy -pl lancedb-core -am -P deploy-to-fury
-DaltDeploymentRepository=fury::file:///tmp/osscout-fury-base — base
build succeeded and emitted stale 0.42.0-beta.20 artifacts for the
0.42.0-beta.21 release sources.
Result: cd java && JAVA_HOME=/tmp/osscout-jdk8 ./mvnw --batch-mode
-DskipTests -Dspotless.skip=true clean deploy -pl lancedb-core -am -P
deploy-to-fury
-DaltDeploymentRepository=fury::file:///tmp/osscout-fury-deploy —
patched build succeeded and emitted both 0.42.0-beta.21 POMs and the
main, sources and Javadoc JARs.
Regression coverage: `ci/tests/test_bump_version.sh`.
<!-- oss-scout-job:job-d5fa2e08-6a6f-46ca-821c-d3a65d054055 -->

Signed-off-by: wangshun <96341168+xixi-box@users.noreply.github.com>
2026-11-23 14:12:57 +08:00

92 lines
3.2 KiB
Bash

#!/usr/bin/env bash
# Run from the repository root with bump-my-version and packaging installed.
set -euo pipefail
work=$(mktemp -d)
trap 'rm -rf "$work"' EXIT
mkdir -p "$work/repo" "$work/bin"
# Release tagging must still include Java's versions when Maven cannot update them.
cat > "$work/bin/mvn" <<'MOCK'
#!/bin/sh
echo "Unable to run Maven versions plugin" >&2
exit 1
MOCK
chmod +x "$work/bin/mvn"
export PATH="$work/bin:$PATH"
git ls-files -z .bumpversion.toml ci/bump_version.sh ci/semver_sort.py \
nodejs/package.json 'nodejs/npm/*/package.json' nodejs/Cargo.toml \
rust/lancedb/Cargo.toml rust/lancedb/cli/Cargo.toml python/Cargo.toml \
docs/src/java/java.md java/pom.xml java/lancedb-core/pom.xml |
tar --null -T - -cf - | tar -xf - -C "$work/repo"
cd "$work/repo"
# The breaking-change check needs GitHub access and runs after the release tag is set.
printf 'pass\n' > ci/check_breaking_changes.py
git init --quiet
git config user.name "Release test"
git config user.email "release-test@example.com"
git add .
git commit --quiet --message "Release baseline"
git tag v0.0.0
current_version=$(python -c 'import tomllib; print(tomllib.load(open(".bumpversion.toml", "rb"))["tool"]["bumpversion"]["current_version"])')
git tag "v$current_version"
# Verify the current baseline before bumping; stale Java POMs must fail.
python - "$current_version" <<'PY'
import sys
import xml.etree.ElementTree as ET
expected = sys.argv[1]
ns = {"m": "http://maven.apache.org/POM/4.0.0"}
for path, xpath in (
("java/pom.xml", "m:version"),
("java/lancedb-core/pom.xml", "m:parent/m:version"),
):
actual = ET.parse(path).getroot().findtext(xpath, namespaces=ns)
if actual != expected:
raise SystemExit(f"Java baseline mismatch in {path}: expected {expected}, got {actual}")
print(f"Java baseline matches {expected} in both POMs")
PY
check_java_release() {
local release_type=$1
local expected_version=$2
bash ci/bump_version.sh "$release_type" false > "$work/bump.log" 2>&1 || {
cat "$work/bump.log"
return 1
}
python - "$release_type" "$expected_version" <<'PY'
import subprocess
import sys
import xml.etree.ElementTree as ET
release_type, expected_version = sys.argv[1:]
case = f"test_java_release_version_matches_tag ({release_type})"
tag = subprocess.check_output(["git", "describe", "--tags", "--exact-match", "HEAD"], text=True).strip()
assert tag == f"v{expected_version}", f"{case}: expected v{expected_version}, got {tag}"
namespace = {"m": "http://maven.apache.org/POM/4.0.0"}
for path, version_path in (
("java/pom.xml", "m:version"),
("java/lancedb-core/pom.xml", "m:parent/m:version"),
):
content = subprocess.check_output(["git", "show", f"{tag}:{path}"])
version = ET.fromstring(content).findtext(version_path, namespaces=namespace)
assert version == expected_version, f"{case}: {path}: expected {expected_version}, got {version}"
print(f"{case}: passed")
PY
}
case "$current_version" in
*-beta.*)
preview_version="${current_version%.*}.$((${current_version##*.} + 1))"
;;
*)
preview_version="${current_version%.*}.$((${current_version##*.} + 1))-beta.0"
;;
esac
check_java_release preview "$preview_version"
check_java_release stable "${preview_version%-beta.*}"