fix(agents): preserve automatic version bumps

This commit is contained in:
t8y2 committed 2026-07-01 14:24:29 +08:00
1 parent 00b5715307
commit 0756b186df
2 files changed
+38 -21

No files matched your search

+36 -19
View File
@@ -34,6 +34,7 @@ jobs:
VERSIONS=$(cat agents/versions.json) VERSIONS=$(cat agents/versions.json)
PREV_VERSIONS="$VERSIONS" PREV_VERSIONS="$VERSIONS"
MANUAL_VERSIONS_CHANGED=false
if [ -z "$PREV_TAG" ]; then if [ -z "$PREV_TAG" ]; then
echo "No previous agents-v tag found; treating this as the first migrated agents release" echo "No previous agents-v tag found; treating this as the first migrated agents release"
@@ -50,9 +51,9 @@ jobs:
echo "Comparing $PREV_TAG..HEAD" echo "Comparing $PREV_TAG..HEAD"
if [ "$SKIP_BUMP" != "true" ] && ! git diff --quiet "$PREV_TAG"..HEAD -- agents/versions.json 2>/dev/null; then if [ "$SKIP_BUMP" != "true" ] && ! git diff --quiet "$PREV_TAG"..HEAD -- agents/versions.json 2>/dev/null; then
echo "Manual agents/versions.json bump detected; using it as the release version source." echo "Manual agents/versions.json changes detected; preserving manually changed module versions and auto-bumping the rest."
PREV_VERSIONS=$(git show "$PREV_TAG:agents/versions.json") PREV_VERSIONS=$(git show "${PREV_TAG}:agents/versions.json")
SKIP_BUMP=true MANUAL_VERSIONS_CHANGED=true
fi fi
CHANGED=false CHANGED=false
@@ -60,6 +61,12 @@ jobs:
if [ "$SKIP_BUMP" = "true" ]; then if [ "$SKIP_BUMP" = "true" ]; then
echo "Skipping automatic module version bump for migrated first release; versions.json was carried over from dbx-agents." echo "Skipping automatic module version bump for migrated first release; versions.json was carried over from dbx-agents."
else else
if git diff --quiet "$PREV_TAG"..HEAD -- agents/common/ 2>/dev/null; then
COMMON_CHANGED=false
else
COMMON_CHANGED=true
fi
for dir in $(echo "$VERSIONS" | python3 -c "import sys,json; [print(k) for k in json.load(sys.stdin)]"); do for dir in $(echo "$VERSIONS" | python3 -c "import sys,json; [print(k) for k in json.load(sys.stdin)]"); do
if [ "$dir" = "oracle" ] && [ -d "agents/drivers/oracle-go" ]; then if [ "$dir" = "oracle" ] && [ -d "agents/drivers/oracle-go" ]; then
CHECK_DIR="drivers/oracle-go" CHECK_DIR="drivers/oracle-go"
@@ -71,30 +78,40 @@ jobs:
continue continue
fi fi
DIFF_PATHS=("agents/$CHECK_DIR/") DIFF_PATHS=("agents/$CHECK_DIR/")
# common changes affect all modules OLD_VER=$(echo "$VERSIONS" | python3 -c "import sys,json; print(json.load(sys.stdin).get('$dir','0.1.0'))")
if git diff --quiet "$PREV_TAG"..HEAD -- agents/common/ 2>/dev/null; then PREV_VER=$(PREV_VERSIONS_JSON="$PREV_VERSIONS" MODULE_NAME="$dir" python3 - <<'PY'
COMMON_CHANGED=false import json, os
else versions = json.loads(os.environ["PREV_VERSIONS_JSON"])
COMMON_CHANGED=true print(versions.get(os.environ["MODULE_NAME"], ""))
fi PY
)
MANUALLY_VERSIONED=false
if [ "$MANUAL_VERSIONS_CHANGED" = "true" ] && { [ -z "$PREV_VER" ] || [ "$PREV_VER" != "$OLD_VER" ]; }; then
MANUALLY_VERSIONED=true
fi
if git diff --quiet "$PREV_TAG"..HEAD -- "${DIFF_PATHS[@]}" 2>/dev/null && [ "$COMMON_CHANGED" = "false" ]; then if git diff --quiet "$PREV_TAG"..HEAD -- "${DIFF_PATHS[@]}" 2>/dev/null && [ "$COMMON_CHANGED" = "false" ]; then
echo " $dir: no changes" echo " $dir: no changes"
elif [ "$MANUALLY_VERSIONED" = "true" ]; then
if [ -z "$PREV_VER" ]; then
echo " $dir: CHANGED, new module version kept at $OLD_VER"
else else
echo " $dir: CHANGED" echo " $dir: CHANGED, manual version $PREV_VER -> $OLD_VER"
OLD_VER=$(echo "$VERSIONS" | python3 -c "import sys,json; print(json.load(sys.stdin).get('$dir','0.1.0'))") fi
IFS='.' read -r major minor patch <<< "$OLD_VER" else
NEW_VER="$major.$minor.$((patch + 1))" echo " $dir: CHANGED"
VERSIONS=$(echo "$VERSIONS" | python3 -c " IFS='.' read -r major minor patch <<< "$OLD_VER"
NEW_VER="$major.$minor.$((patch + 1))"
VERSIONS=$(echo "$VERSIONS" | python3 -c "
import sys, json import sys, json
d = json.load(sys.stdin) d = json.load(sys.stdin)
d['$dir'] = '$NEW_VER' d['$dir'] = '$NEW_VER'
json.dump(d, sys.stdout, indent=2) json.dump(d, sys.stdout, indent=2)
print() print()
") ")
CHANGED=true CHANGED=true
echo " $dir: $OLD_VER -> $NEW_VER" echo " $dir: $OLD_VER -> $NEW_VER"
fi fi
done done
fi fi
+2 -2
View File
@@ -18,7 +18,7 @@
"kylin": "0.1.25", "kylin": "0.1.25",
"neo4j": "0.1.25", "neo4j": "0.1.25",
"oceanbase-oracle": "0.1.20", "oceanbase-oracle": "0.1.20",
"oracle": "0.1.29", "oracle": "0.1.30",
"snowflake": "0.1.25", "snowflake": "0.1.25",
"saphana": "0.1.20", "saphana": "0.1.20",
"sundb": "0.1.25", "sundb": "0.1.25",
@@ -27,7 +27,7 @@
"trino": "0.1.25", "trino": "0.1.25",
"vastbase": "0.1.25", "vastbase": "0.1.25",
"vertica": "0.1.20", "vertica": "0.1.20",
"mongodb": "0.1.24", "mongodb": "0.1.25",
"highgo": "0.1.23", "highgo": "0.1.23",
"yashandb": "0.1.21", "yashandb": "0.1.21",
"oscar": "0.1.0", "oscar": "0.1.0",