Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

fix(jdbc): stabilize plugin release versioning

t8y27badf4060ede
diff --git a/.github/scripts/check-jdbc-plugin-version.mjs b/.github/scripts/check-jdbc-plugin-version.mjs
new file mode 100644
index 0000000000..8e3d098e3c
--- /dev/null
+++ b/.github/scripts/check-jdbc-plugin-version.mjs
@@ -0,0 +1,80 @@
+#!/usr/bin/env node
+import { execFileSync } from "node:child_process";
+
+const POM_PATH = "plugins/jdbc/pom.xml";
+const MANIFEST_PATH = "plugins/jdbc/manifest.json";
+
+function firstProjectVersion(pomXml) {
+ const match = pomXml.match(/<project[\s\S]*?<version>([^<]+)<\/version>/);
+ return match?.[1]?.trim() ?? "";
+}
+
+function manifestVersion(manifestJson) {
+ return JSON.parse(manifestJson).version ?? "";
+}
+
+function isRelevantJdbcPluginChange(file) {
+ if (!file.startsWith("plugins/jdbc/")) return false;
+ if (file.startsWith("plugins/jdbc/dist/") || file.startsWith("plugins/jdbc/target/")) return false;
+ if (file === "plugins/jdbc/README.md" || file === "plugins/jdbc/package.sh") return false;
+ return true;
+}
+
+export function evaluateJdbcPluginVersionChange({
+ changedFiles,
+ basePomVersion,
+ baseManifestVersion,
+ headPomVersion,
+ headManifestVersion,
+}) {
+ const errors = [];
+ if (headPomVersion !== headManifestVersion) {
+ errors.push(`JDBC plugin version mismatch: pom.xml is ${headPomVersion} but manifest.json is ${headManifestVersion}.`);
+ return errors;
+ }
+
+ const baseVersion = basePomVersion || baseManifestVersion;
+ const relevantChanged = changedFiles.some(isRelevantJdbcPluginChange);
+ if (relevantChanged && headPomVersion === baseVersion) {
+ errors.push(
+ `JDBC plugin files changed, but the plugin version is still ${headPomVersion}. Bump plugins/jdbc/pom.xml and plugins/jdbc/manifest.json.`,
+ );
+ }
+ return errors;
+}
+
+function git(args) {
+ return execFileSync("git", args, { encoding: "utf8" }).trim();
+}
+
+function readFileAt(ref, path) {
+ return git(["show", `${ref}:${path}`]);
+}
+
+function main() {
+ const [baseRef = "HEAD~1", headRef = "HEAD"] = process.argv.slice(2);
+ const changedFiles = git(["diff", "--name-only", baseRef, headRef]).split("\n").filter(Boolean);
+ const basePomVersion = firstProjectVersion(readFileAt(baseRef, POM_PATH));
+ const baseManifestVersion = manifestVersion(readFileAt(baseRef, MANIFEST_PATH));
+ const headPomVersion = firstProjectVersion(readFileAt(headRef, POM_PATH));
+ const headManifestVersion = manifestVersion(readFileAt(headRef, MANIFEST_PATH));
+ const errors = evaluateJdbcPluginVersionChange({
+ changedFiles,
+ basePomVersion,
+ baseManifestVersion,
+ headPomVersion,
+ headManifestVersion,
+ });
+
+ if (errors.length) {
+ for (const error of errors) {
+ console.error(`::error::${error}`);
+ }
+ process.exit(1);
+ }
+ console.log(`JDBC plugin version check passed (${headPomVersion}).`);
+}
+
+if (import.meta.url === `file://${process.argv[1]}`) {
+ main();
+}
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 657b199af5..56a05fec5f 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -11,6 +11,8 @@ jobs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
@@ -65,5 +67,14 @@ jobs:
- name: Cargo check
run: cargo check --workspace --locked
+ - name: JDBC plugin version guard
+ env:
+ BASE_SHA: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
+ run: |
+ if [ -z "$BASE_SHA" ] || echo "$BASE_SHA" | grep -Eq '^0+$'; then
+ BASE_SHA="HEAD~1"
+ fi
+ node .github/scripts/check-jdbc-plugin-version.mjs "$BASE_SHA" HEAD
+
- name: JDBC plugin package check
run: ./plugins/jdbc/package.sh
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 9dcff5eee1..afddbf1725 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -189,6 +189,7 @@ jobs:
run: |
gh release upload "${GITHUB_REF_NAME}" \
"plugins/jdbc/dist/dbx-jdbc-plugin-${{ steps.jdbc-plugin.outputs.version }}.zip" \
+ "plugins/jdbc/dist/dbx-jdbc-plugin-latest.zip" \
--repo "${GITHUB_REPOSITORY}" \
--clobber
diff --git a/.gitignore b/.gitignore
index 2f5eb3476d..383b168c48 100644
--- a/.gitignore
+++ b/.gitignore
@@ -33,6 +33,7 @@ Thumbs.db
# GitHub (keep workflows)
.github/*
!.github/workflows/
+!.github/scripts/
!.github/ISSUE_TEMPLATE/
# Env
diff --git a/packages/app-tests/jdbcPluginRelease.test.ts b/packages/app-tests/jdbcPluginRelease.test.ts
new file mode 100644
index 0000000000..9fd8bec0d3
--- /dev/null
+++ b/packages/app-tests/jdbcPluginRelease.test.ts
@@ -0,0 +1,55 @@
+import { strict as assert } from "node:assert";
+import test from "node:test";
+import { evaluateJdbcPluginVersionChange } from "../../.github/scripts/check-jdbc-plugin-version.mjs";
+
+test("requires a JDBC plugin version bump when runtime files change", () => {
+ assert.deepEqual(
+ evaluateJdbcPluginVersionChange({
+ changedFiles: ["plugins/jdbc/src/main/java/app/dbx/jdbc/DbxJdbcPlugin.java"],
+ basePomVersion: "0.1.1",
+ baseManifestVersion: "0.1.1",
+ headPomVersion: "0.1.1",
+ headManifestVersion: "0.1.1",
+ }),
+ ["JDBC plugin files changed, but the plugin version is still 0.1.1. Bump plugins/jdbc/pom.xml and plugins/jdbc/manifest.json."],
+ );
+});
+
+test("allows JDBC plugin runtime changes when pom and manifest versions are bumped together", () => {
+ assert.deepEqual(
+ evaluateJdbcPluginVersionChange({
+ changedFiles: ["plugins/jdbc/src/main/java/app/dbx/jdbc/DbxJdbcPlugin.java"],
+ basePomVersion: "0.1.1",
+ baseManifestVersion: "0.1.1",
+ headPomVersion: "0.1.2",
+ headManifestVersion: "0.1.2",
+ }),
+ [],
+ );
+});
+
+test("does not require a JDBC plugin version bump for docs or release packaging changes", () => {
+ assert.deepEqual(
+ evaluateJdbcPluginVersionChange({
+ changedFiles: ["plugins/jdbc/README.md", "plugins/jdbc/package.sh"],
+ basePomVersion: "0.1.1",
+ baseManifestVersion: "0.1.1",
+ headPomVersion: "0.1.1",
+ headManifestVersion: "0.1.1",
+ }),
+ [],
+ );
+});
+
+test("requires JDBC plugin pom and manifest versions to match", () => {
+ assert.deepEqual(
+ evaluateJdbcPluginVersionChange({
+ changedFiles: ["plugins/jdbc/manifest.json"],
+ basePomVersion: "0.1.1",
+ baseManifestVersion: "0.1.1",
+ headPomVersion: "0.1.2",
+ headManifestVersion: "0.1.1",
+ }),
+ ["JDBC plugin version mismatch: pom.xml is 0.1.2 but manifest.json is 0.1.1."],
+ );
+});
diff --git a/plugins/jdbc/README.md b/plugins/jdbc/README.md
index de9c61e0ac..f69d3c029b 100644
--- a/plugins/jdbc/README.md
+++ b/plugins/jdbc/README.md
@@ -17,6 +17,7 @@ cp target/dbx-jdbc-plugin-*-all.jar lib/dbx-jdbc-plugin.jar
```
The package version follows the JDBC plugin version in `pom.xml` and `manifest.json`.
+The package script writes both `dbx-jdbc-plugin-<version>.zip` and `dbx-jdbc-plugin-latest.zip`.
## Install for local DBX
diff --git a/plugins/jdbc/package.sh b/plugins/jdbc/package.sh
index d3a3cc1184..200c8f24f2 100755
--- a/plugins/jdbc/package.sh
+++ b/plugins/jdbc/package.sh
@@ -5,11 +5,12 @@ ROOT="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)"
VERSION="$(grep -m1 '<version>' "$ROOT/pom.xml" | sed -E 's/.*<version>([^<]+)<.*/\1/')"
PACKAGE_DIR="$ROOT/dist/dbx-jdbc-plugin-$VERSION"
ZIP_PATH="$ROOT/dist/dbx-jdbc-plugin-$VERSION.zip"
+LATEST_ZIP_PATH="$ROOT/dist/dbx-jdbc-plugin-latest.zip"
cd "$ROOT"
mvn -q -DskipTests package
-rm -rf "$PACKAGE_DIR" "$ZIP_PATH"
+rm -rf "$PACKAGE_DIR" "$ZIP_PATH" "$LATEST_ZIP_PATH"
mkdir -p "$PACKAGE_DIR/bin" "$PACKAGE_DIR/lib"
cp "$ROOT/manifest.json" "$PACKAGE_DIR/manifest.json"
cp "$ROOT/bin/dbx-jdbc-plugin" "$PACKAGE_DIR/bin/dbx-jdbc-plugin"
@@ -18,4 +19,6 @@ cp "$ROOT/target/dbx-jdbc-plugin-$VERSION-all.jar" "$PACKAGE_DIR/lib/dbx-jdbc-pl
chmod +x "$PACKAGE_DIR/bin/dbx-jdbc-plugin"
(cd "$ROOT/dist" && zip -qr "dbx-jdbc-plugin-$VERSION.zip" "dbx-jdbc-plugin-$VERSION")
+cp "$ZIP_PATH" "$LATEST_ZIP_PATH"
echo "$ZIP_PATH"
+echo "$LATEST_ZIP_PATH"
diff --git a/src-tauri/src/commands/plugins.rs b/src-tauri/src/commands/plugins.rs
index 56aff90789..fb63647ce0 100644
--- a/src-tauri/src/commands/plugins.rs
+++ b/src-tauri/src/commands/plugins.rs
@@ -6,8 +6,9 @@ use serde::Serialize;
use super::connection::AppState;
-const JDBC_PLUGIN_DOWNLOAD_URL: &str = "https://github.com/t8y2/dbx/releases/latest/download/dbx-jdbc-plugin-0.1.1.zip";
-const JDBC_PLUGIN_R2_PATH: &str = "releases/latest/dbx-jdbc-plugin-0.1.1.zip";
+const JDBC_PLUGIN_DOWNLOAD_URL: &str =
+ "https://github.com/t8y2/dbx/releases/latest/download/dbx-jdbc-plugin-latest.zip";
+const JDBC_PLUGIN_R2_PATH: &str = "releases/latest/dbx-jdbc-plugin-latest.zip";
#[tauri::command]
pub async fn list_plugins(state: State<'_, Arc<AppState>>) -> Result<Vec<InstalledPlugin>, String> {