mirror of
https://github.com/lancedb/lancedb.git
synced 2026-10-21 11:12:27 +00:00
fix: preserve the stable Java release version
This commit is contained in:
+1
-4
@@ -29,10 +29,7 @@ allow_shell_hooks = true
|
||||
# Java maven files
|
||||
pre_commit_hooks = [
|
||||
"""
|
||||
NEW_VERSION="${BVHOOK_NEW_MAJOR}.${BVHOOK_NEW_MINOR}.${BVHOOK_NEW_PATCH}"
|
||||
if [ ! -z "$BVHOOK_NEW_PRE_L" ] && [ ! -z "$BVHOOK_NEW_PRE_N" ]; then
|
||||
NEW_VERSION="${NEW_VERSION}-${BVHOOK_NEW_PRE_L}.${BVHOOK_NEW_PRE_N}"
|
||||
fi
|
||||
NEW_VERSION="$BVHOOK_NEW_VERSION"
|
||||
echo "Constructed new version: $NEW_VERSION"
|
||||
cd java && mvn versions:set -DnewVersion=$NEW_VERSION && mvn versions:commit
|
||||
|
||||
|
||||
@@ -5,11 +5,13 @@ on:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- .bumpversion.toml
|
||||
- ci/set_lance_version.py
|
||||
- ci/tests/**
|
||||
- .github/workflows/ci-scripts.yml
|
||||
pull_request:
|
||||
paths:
|
||||
- .bumpversion.toml
|
||||
- ci/set_lance_version.py
|
||||
- ci/tests/**
|
||||
- .github/workflows/ci-scripts.yml
|
||||
@@ -26,5 +28,7 @@ jobs:
|
||||
- uses: actions/setup-python@v6
|
||||
with:
|
||||
python-version: "3.13"
|
||||
- name: Install release tooling
|
||||
run: pip install bump-my-version
|
||||
- name: Run tests
|
||||
run: python -m unittest discover -s ci/tests -v
|
||||
|
||||
@@ -12,6 +12,13 @@
|
||||
|
||||
name: Build and publish Java packages
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
dry_run:
|
||||
description: Build without publishing to Maven Central
|
||||
type: boolean
|
||||
default: true
|
||||
required: true
|
||||
push:
|
||||
tags:
|
||||
- "v*"
|
||||
@@ -48,12 +55,25 @@ jobs:
|
||||
run: |
|
||||
git config --global user.email "dev+gha@lancedb.com"
|
||||
git config --global user.name "LanceDB Github Runner"
|
||||
- name: Validate package version
|
||||
run: |
|
||||
python - <<'PYTHON'
|
||||
import tomllib
|
||||
import xml.etree.ElementTree as ET
|
||||
from pathlib import Path
|
||||
|
||||
expected = tomllib.loads(Path("../.bumpversion.toml").read_text())["tool"]["bumpversion"]["current_version"]
|
||||
actual = ET.parse("pom.xml").findtext("{http://maven.apache.org/POM/4.0.0}version")
|
||||
if actual != expected:
|
||||
raise ValueError(f"Maven version {actual} differs from release version {expected}")
|
||||
print(f"Validated Maven version {actual}")
|
||||
PYTHON
|
||||
- name: Dry run
|
||||
if: github.event_name == 'pull_request'
|
||||
if: github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && inputs.dry_run)
|
||||
run: |
|
||||
./mvnw --batch-mode -DskipTests package -pl lancedb-core -am
|
||||
- name: Publish
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
if: startsWith(github.ref, 'refs/tags/v') || (github.event_name == 'workflow_dispatch' && !inputs.dry_run)
|
||||
run: |
|
||||
echo "use-agent" >> ~/.gnupg/gpg.conf
|
||||
echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf
|
||||
@@ -68,7 +88,7 @@ jobs:
|
||||
name: Report Workflow Failure
|
||||
runs-on: ubuntu-latest
|
||||
needs: [publish]
|
||||
if: always() && failure() && startsWith(github.ref, 'refs/tags/v')
|
||||
if: always() && failure() && (startsWith(github.ref, 'refs/tags/v') || (github.event_name == 'workflow_dispatch' && !inputs.dry_run))
|
||||
permissions:
|
||||
contents: read
|
||||
issues: write
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright The LanceDB Authors
|
||||
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[2]
|
||||
|
||||
|
||||
class ReleaseVersionTests(unittest.TestCase):
|
||||
def check_bump(self, part, expected):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
config = (REPO_ROOT / ".bumpversion.toml").read_text()
|
||||
config = config.split("[[tool.bumpversion.files]]", 1)[0]
|
||||
config = re.sub(
|
||||
r'^current_version = ".*"$',
|
||||
'current_version = "0.40.0-beta.12"',
|
||||
config,
|
||||
flags=re.MULTILINE,
|
||||
)
|
||||
config += '\n[[tool.bumpversion.files]]\nfilename = "version.txt"\n'
|
||||
(root / ".bumpversion.toml").write_text(config)
|
||||
(root / "version.txt").write_text("0.40.0-beta.12\n")
|
||||
(root / "java").mkdir()
|
||||
(root / "java" / "pom.xml").write_text("0.40.0-beta.12\n")
|
||||
(root / "bin").mkdir()
|
||||
maven = root / "bin" / "mvn"
|
||||
# Record the effective Maven version while exercising the real
|
||||
# bump-my-version parser, serialization, hook environment, and git hook.
|
||||
maven.write_text(
|
||||
'#!/bin/sh\nfor arg in "$@"; do\n'
|
||||
' case "$arg" in\n'
|
||||
' -DnewVersion=*) printf "%s\\n" "${arg#-DnewVersion=}" > pom.xml;;\n'
|
||||
" esac\ndone\n"
|
||||
)
|
||||
maven.chmod(0o755)
|
||||
env = dict(
|
||||
os.environ, PATH=f"{root / 'bin'}{os.pathsep}{os.environ['PATH']}"
|
||||
)
|
||||
|
||||
def run(*args):
|
||||
return subprocess.run(
|
||||
args,
|
||||
cwd=root,
|
||||
env=env,
|
||||
text=True,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT,
|
||||
check=True,
|
||||
)
|
||||
|
||||
run("git", "init", "-q")
|
||||
run("git", "config", "user.name", "Release Test")
|
||||
run("git", "config", "user.email", "release-test@example.invalid")
|
||||
run("git", "config", "commit.gpgsign", "false")
|
||||
run("git", "add", ".")
|
||||
run("git", "commit", "-qm", "Initial version")
|
||||
run("bump-my-version", "bump", part)
|
||||
self.assertEqual((root / "version.txt").read_text().strip(), expected)
|
||||
self.assertEqual((root / "java" / "pom.xml").read_text().strip(), expected)
|
||||
self.assertEqual(
|
||||
run("git", "describe", "--exact-match").stdout.strip(), f"v{expected}"
|
||||
)
|
||||
|
||||
def test_stable_maven_version_matches_release(self):
|
||||
self.check_bump("pre_l", "0.40.0")
|
||||
|
||||
def test_preview_maven_version_matches_release(self):
|
||||
self.check_bump("pre_n", "0.40.0-beta.13")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -8,7 +8,7 @@
|
||||
<parent>
|
||||
<groupId>com.lancedb</groupId>
|
||||
<artifactId>lancedb-parent</artifactId>
|
||||
<version>0.40.0-final.0</version>
|
||||
<version>0.40.0</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>com.lancedb</groupId>
|
||||
<artifactId>lancedb-parent</artifactId>
|
||||
<version>0.40.0-final.0</version>
|
||||
<version>0.40.0</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>${project.artifactId}</name>
|
||||
<description>LanceDB Java SDK Parent POM</description>
|
||||
|
||||
Reference in New Issue
Block a user