This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch CAMEL-23648
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 614913c056fd6a3593fcd0d4a483675e4c2a04e2
Author: Claus Ibsen <[email protected]>
AuthorDate: Fri May 29 16:11:31 2026 +0200

    CAMEL-23648: Update container version workflow to regenerate metadata.json
    
    Co-Authored-By: Claude Opus 4.6 <[email protected]>
---
 .../update-metadata-version.py                     | 104 +++++++++++++++++++++
 .github/workflows/check-container-versions.yml     |   9 +-
 2 files changed, 112 insertions(+), 1 deletion(-)

diff --git a/.github/actions/check-container-upgrade/update-metadata-version.py 
b/.github/actions/check-container-upgrade/update-metadata-version.py
new file mode 100644
index 000000000000..27f99efa4460
--- /dev/null
+++ b/.github/actions/check-container-upgrade/update-metadata-version.py
@@ -0,0 +1,104 @@
+#!/usr/bin/env python3
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+#
+
+"""
+Update serviceVersion in test-infra metadata.json files when a container
+image version is bumped. Produces output matching Jackson's 
DefaultPrettyPrinter
+format so the result is identical to what the Maven build generates.
+
+Usage:
+    python3 update-metadata-version.py <artifact-id> <old-version> 
<new-version> <metadata-file> [<metadata-file2> ...]
+"""
+
+import json
+import os
+import sys
+
+
+def jackson_format(data):
+    """Serialize JSON to match Jackson's DefaultPrettyPrinter output."""
+    lines = []
+    for i, entry in enumerate(data):
+        lines.append("[ {" if i == 0 else "}, {")
+        keys = list(entry.keys())
+        for j, key in enumerate(keys):
+            value = entry[key]
+            if isinstance(value, list):
+                if not value:
+                    formatted = "[ ]"
+                else:
+                    items = ", ".join(f'"{v}"' for v in value)
+                    formatted = f"[ {items} ]"
+            elif value is None:
+                formatted = "null"
+            elif isinstance(value, str):
+                formatted = f'"{value}"'
+            else:
+                formatted = json.dumps(value)
+            comma = "," if j < len(keys) - 1 else ""
+            lines.append(f'  "{key}" : {formatted}{comma}')
+    lines.append("} ]")
+    return "\n".join(lines)
+
+
+def update_metadata(artifact_id, old_version, new_version, metadata_file):
+    """Update serviceVersion for entries matching the artifact and old 
version."""
+    if not os.path.isfile(metadata_file):
+        print(f"⚠️  {metadata_file} not found, skipping")
+        return False
+
+    with open(metadata_file, "r", encoding="utf-8") as f:
+        data = json.load(f)
+
+    updated = False
+    for entry in data:
+        if (
+            entry.get("artifactId") == artifact_id
+            and entry.get("serviceVersion") == old_version
+        ):
+            entry["serviceVersion"] = new_version
+            updated = True
+
+    if updated:
+        with open(metadata_file, "w", encoding="utf-8") as f:
+            f.write(jackson_format(data))
+        print(f"✅ Updated serviceVersion {old_version} → {new_version} in 
{metadata_file}")
+    else:
+        print(f"ℹ️  No matching entries for {artifact_id}/{old_version} in 
{metadata_file}")
+
+    return updated
+
+
+def main():
+    if len(sys.argv) < 5:
+        print(
+            "Usage: update-metadata-version.py <artifact-id> <old-version> 
<new-version> <metadata-file> [<metadata-file2> ...]"
+        )
+        sys.exit(1)
+
+    artifact_id = sys.argv[1]
+    old_version = sys.argv[2]
+    new_version = sys.argv[3]
+    metadata_files = sys.argv[4:]
+
+    for metadata_file in metadata_files:
+        update_metadata(artifact_id, old_version, new_version, metadata_file)
+
+
+if __name__ == "__main__":
+    main()
diff --git a/.github/workflows/check-container-versions.yml 
b/.github/workflows/check-container-versions.yml
index a29b3962e970..e1777dfc1c57 100644
--- a/.github/workflows/check-container-versions.yml
+++ b/.github/workflows/check-container-versions.yml
@@ -306,8 +306,15 @@ jobs:
             # Create and switch to new branch
             git checkout -b "$BRANCH_NAME"
 
+            # Update serviceVersion in metadata.json files
+            
METADATA_INFRA="test-infra/camel-test-infra-all/src/generated/resources/META-INF/metadata.json"
+            
METADATA_CATALOG="catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/test-infra/metadata.json"
+            python3 
.github/actions/check-container-upgrade/update-metadata-version.py \
+              "$MODULE_NAME" "$OLD_VERSION" "$NEW_VERSION" \
+              "$METADATA_INFRA" "$METADATA_CATALOG"
+
             # Add and commit changes
-            git add "$FILE_PATH"
+            git add "$FILE_PATH" "$METADATA_INFRA" "$METADATA_CATALOG"
             git commit -m "$COMMIT_MSG"
 
             # Push branch

Reply via email to