You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by xu...@apache.org on 2024/06/30 09:00:26 UTC

(opendal) 01/01: ci(scripts): Add a script to generate version list

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

xuanwo pushed a commit to branch add-script-version
in repository https://gitbox.apache.org/repos/asf/opendal.git

commit cfdae92b174f419d0c6adb57951a27aba9bf5a91
Author: Xuanwo <gi...@xuanwo.io>
AuthorDate: Sun Jun 30 16:59:58 2024 +0800

    ci(scripts): Add a script to generate version list
    
    Signed-off-by: Xuanwo <gi...@xuanwo.io>
---
 scripts/constants.py           |  9 +--------
 scripts/dependencies.py        | 13 ++++++-------
 scripts/merge_local_staging.py |  2 +-
 scripts/release.py             |  8 +++++++-
 scripts/verify.py              |  4 +++-
 scripts/version.py             | 35 +++++++++++++++++++++++++++++++++++
 6 files changed, 53 insertions(+), 18 deletions(-)

diff --git a/scripts/constants.py b/scripts/constants.py
index edd16c44f8..de66cc62f0 100755
--- a/scripts/constants.py
+++ b/scripts/constants.py
@@ -61,7 +61,7 @@ def get_rust_package_version(path):
 #
 # For examples:
 # core: `0.45.0`
-# packages depends on core: `0.1.0+core.0.45.0`
+# packages depends on core: `0.1.0`
 def get_package_version(package):
     if package == "core":
         return get_rust_package_version("core")
@@ -78,10 +78,3 @@ def get_package_version(package):
     #
     # However, those packages are not mature enough, it's much easier for us to always return `0.0.0` instead.
     return f"0.0.0"
-
-
-if __name__ == "__main__":
-    for v in PACKAGES:
-        print(
-            f"{v}: version={get_package_version(v)}"
-        )
diff --git a/scripts/dependencies.py b/scripts/dependencies.py
index 48a6f285f1..6e517b4474 100755
--- a/scripts/dependencies.py
+++ b/scripts/dependencies.py
@@ -21,6 +21,7 @@ from pathlib import Path
 import subprocess
 from constants import PACKAGES
 
+
 def check_deps():
     cargo_dirs = PACKAGES
     for root in cargo_dirs:
@@ -50,18 +51,16 @@ if __name__ == "__main__":
     subparsers = parser.add_subparsers()
 
     parser_check = subparsers.add_parser(
-        'check',
-        description="Check dependencies",
-        help="Check dependencies")
+        "check", description="Check dependencies", help="Check dependencies"
+    )
     parser_check.set_defaults(func=check_deps)
 
     parser_generate = subparsers.add_parser(
-        'generate',
-        description="Generate dependencies",
-        help="Generate dependencies")
+        "generate", description="Generate dependencies", help="Generate dependencies"
+    )
     parser_generate.set_defaults(func=generate_deps)
 
     args = parser.parse_args()
     arg_dict = dict(vars(args))
-    del arg_dict['func']
+    del arg_dict["func"]
     args.func(**arg_dict)
diff --git a/scripts/merge_local_staging.py b/scripts/merge_local_staging.py
index b63a215b48..e60f9c0db5 100644
--- a/scripts/merge_local_staging.py
+++ b/scripts/merge_local_staging.py
@@ -53,7 +53,7 @@ def print_directory_contents(directory, prefix=""):
 
 
 def print_index_contents(directory):
-    for sub_dir in directory.rglob('.index'):
+    for sub_dir in directory.rglob(".index"):
         with sub_dir.open("r") as file:
             print(file.read())
 
diff --git a/scripts/release.py b/scripts/release.py
index 7341b68510..767357617e 100755
--- a/scripts/release.py
+++ b/scripts/release.py
@@ -84,7 +84,13 @@ def generate_checksum():
     for i in Path(ROOT_DIR / "dist").glob("*.tar.gz"):
         print(f"Check checksum for {i}")
         subprocess.run(
-            ["shasum", "-a", "512", "-c", f"{str(i.relative_to(ROOT_DIR / 'dist'))}.sha512"],
+            [
+                "shasum",
+                "-a",
+                "512",
+                "-c",
+                f"{str(i.relative_to(ROOT_DIR / 'dist'))}.sha512",
+            ],
             cwd=ROOT_DIR / "dist",
             check=True,
         )
diff --git a/scripts/verify.py b/scripts/verify.py
index ac2ff73c48..6620ce9806 100755
--- a/scripts/verify.py
+++ b/scripts/verify.py
@@ -146,7 +146,9 @@ if __name__ == "__main__":
                 print(
                     "Cargo is not found, please check if rust development has been setup correctly"
                 )
-                print("Visit https://www.rust-lang.org/tools/install for more information")
+                print(
+                    "Visit https://www.rust-lang.org/tools/install for more information"
+                )
                 sys.exit(1)
 
         if "java" in dir.name:
diff --git a/scripts/version.py b/scripts/version.py
new file mode 100755
index 0000000000..fde8f54b91
--- /dev/null
+++ b/scripts/version.py
@@ -0,0 +1,35 @@
+#!/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.
+
+from constants import PACKAGES, get_package_version
+
+
+def increment_patch_version(version):
+    parts = version.split(".")
+    parts[-1] = str(int(parts[-1]) + 1)
+    return ".".join(parts)
+
+
+if __name__ == "__main__":
+    print(f"| {'Name':<25} | {'Version':<7} | {'Next':<7} |")
+    print(f"| {'-':<25} | {'-':<7} | {'-':<7} |")
+    for v in PACKAGES:
+        cur = get_package_version(v)
+        next = increment_patch_version(cur)
+
+        print(f"| {str(v):<25} | {cur:<7} | {next:<7} |")