Skip to content

Commit

Permalink
ci(scripts): Add a script to generate version list (#4827)
Browse files Browse the repository at this point in the history
* ci(scripts): Add a script to generate version list

Signed-off-by: Xuanwo <[email protected]>

* Add comments

Signed-off-by: Xuanwo <[email protected]>

---------

Signed-off-by: Xuanwo <[email protected]>
  • Loading branch information
Xuanwo authored Jun 30, 2024
1 parent e51425c commit de9fbf6
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 19 deletions.
9 changes: 1 addition & 8 deletions scripts/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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)}"
)
13 changes: 6 additions & 7 deletions scripts/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import subprocess
from constants import PACKAGES


def check_deps():
cargo_dirs = PACKAGES
for root in cargo_dirs:
Expand Down Expand Up @@ -50,18 +51,16 @@ def generate_deps():
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)
2 changes: 1 addition & 1 deletion scripts/merge_local_staging.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand Down
8 changes: 7 additions & 1 deletion scripts/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
4 changes: 3 additions & 1 deletion scripts/verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ def build_java_binding(dir):
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:
Expand Down
35 changes: 35 additions & 0 deletions scripts/version.py
Original file line number Diff line number Diff line change
@@ -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} |")
17 changes: 16 additions & 1 deletion website/community/release/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,14 @@ This issue is used to track tasks of the opendal ${opendal_version} release.

### Blockers

> Blockers are the tasks that must be completed before the release.
<!-- Blockers are the tasks that must be completed before the release. -->

### Build Release

#### Relelase List

<!-- Generate release list by `./scripts/version.py`, please adapt with the actual needs. -->

#### GitHub Side

- [ ] Bump version in project
Expand Down Expand Up @@ -122,6 +126,17 @@ This issue is used to track tasks of the opendal ${opendal_version} release.
For details of each step, please refer to: https://opendal.apache.org/community/release/
```

## Release List

Use `./script/version.py` to generate a release version list for review.

This list bumps `patch` version by default, please adapt with the actual needs.

For example:

- If breaking change happened, we need to bump `minor` version instead of `patch`.
- If this package is not ready for release, we can skip it.

## GitHub Side

### Bump version in project
Expand Down

0 comments on commit de9fbf6

Please sign in to comment.