From ff68b0384d53d27de57b7541b18793c88ce72122 Mon Sep 17 00:00:00 2001 From: Kazuaki Matsuo Date: Thu, 14 Aug 2025 13:24:37 +0900 Subject: [PATCH 1/7] chore: use semantic-release for most of release script execution --- CHANGELOG.md | 10 +++++-- README.md | 13 +++++++--- pyproject.toml | 2 +- script/release.py | 66 +---------------------------------------------- 4 files changed, 19 insertions(+), 72 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f2ca9ad7..781a92d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,18 @@ # CHANGELOG + ## Unreleased ### Chores -- Add python-semantic-release as the deps - ([`0a2ffad`](https://github.com/appium/python-client/commit/0a2ffad9f3fb37f7ef5ef6632514f07e1fc97359)) +- Revert version created by release script checking + ([#1164](https://github.com/appium/python-client/pull/1164), + [`04a8580`](https://github.com/appium/python-client/commit/04a8580f999843bc9d121c1ed4ce872761350f31)) + +- Use semantic release changelog instead of gitchangelog + ([#1163](https://github.com/appium/python-client/pull/1163), + [`dd3709e`](https://github.com/appium/python-client/commit/dd3709e084e802d6534d51151be1bd45456a4ebd)) ### Documentation diff --git a/README.md b/README.md index 4fae30c0..a6dc3e3f 100644 --- a/README.md +++ b/README.md @@ -530,12 +530,17 @@ uv run pytest -n 2 test/functional/ios/search_context/find_by_ios_class_chain_te Follow the below steps. ```bash -uv pip install setuptools +# Used to publish the package to pypi uv pip install twine -# Type the new version number and 'yes' if you can publish it -# You can test the command with DRY_RUN -DRY_RUN=1 ./release.sh + +rm -rf dist +# bumping the version, building a package and creating a tag. +uv run semantic-release version --patch|--minor|--major + +# this 'release' script now has pushing built modules to pypi only. ./release.sh # release + +# input the same version ``` If the `pypi` was not able to publish with user name and password, please try out `-u` and `-p` option by yourself with `twine` such as `twine upload -u -p dist/Appium-Python-Client-4.1.0.tar.gz`. diff --git a/pyproject.toml b/pyproject.toml index fc8427bf..bd235b26 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -102,7 +102,7 @@ prerelease = false [tool.semantic_release.changelog] exclude_commit_patterns = [] mode = "update" -insertion_flag = "=========\nCHANGELOG\n=========" +insertion_flag = "" template_dir = "templates" [tool.semantic_release.changelog.default_templates] diff --git a/script/release.py b/script/release.py index 4e890f16..88a37e31 100644 --- a/script/release.py +++ b/script/release.py @@ -35,7 +35,7 @@ def print_current_version(): def get_new_version(): - print(MESSAGE_GREEN.format('new version:')) + print(MESSAGE_GREEN.format('Pushing version:')) for line in sys.stdin: return line.rstrip() @@ -53,17 +53,6 @@ def call_bash_script(cmd): else: os.system(cmd) - -def commit_version_code(new_version_num): - call_bash_script('git commit pyproject.toml uv.lock -m "Bump {}"'.format(new_version_num)) - - -def tag_and_generate_changelog(new_version_num): - call_bash_script('git tag "v{}"'.format(new_version_num)) - call_bash_script('uv run semantic-release changelog') - call_bash_script('git commit {} -m "Update changelog for {}"'.format(CHANGELOG_PATH, new_version_num)) - - def upload_sdist(new_version_num): wheel_file = 'dist/appium_python_client-{}-py3-none-any.whl'.format(new_version_num) push_file = 'dist/appium_python_client-{}.tar.gz'.format(new_version_num) @@ -76,12 +65,6 @@ def upload_sdist(new_version_num): ) ) - -def push_changes_to_master(new_version_num): - call_bash_script('git push origin master') - call_bash_script('git push origin "v{}"'.format(new_version_num)) - - def ensure_publication(new_version_num): if os.environ.get('DRY_RUN') is not None: print('Run with {} mode.'.format(MESSAGE_RED.format('[DRY_RUN]'))) @@ -92,66 +75,19 @@ def ensure_publication(new_version_num): return sys.exit('Canceled release process.') - -def build_sdist(): - call_bash_script('uv build') - - -def build() -> None: - shutil.rmtree(BUILT_APPIUM_DIR_PATH, ignore_errors=True) - status, output = subprocess.getstatusoutput('uv run python setup.py install') - if status != 0: - sys.exit(f'Failed to build the package:\n{output}') - - def get_py_files_in_dir(root_dir: str) -> List[str]: return [ file_path[len(root_dir) :] for file_path in glob.glob(f'{root_dir}/**/*.py', recursive=True) + glob.glob(f'{root_dir}/**/*.typed', recursive=True) ] - -def assert_files_count_in_package() -> None: - original_files = get_py_files_in_dir(APPIUM_DIR_PATH) - built_files = get_py_files_in_dir(BUILT_APPIUM_DIR_PATH) - - if len(original_files) != len(built_files): - print(f"The count of files in '{APPIUM_DIR_PATH}' and '{BUILT_APPIUM_DIR_PATH}' were different.") - - original_files_set = set(original_files) - built_files_set = set(built_files) - - diff = original_files_set.difference(built_files_set) - if diff: - print(f"'{APPIUM_DIR_PATH}' has '{diff}' files than {BUILT_APPIUM_DIR_PATH}") - diff = built_files_set.difference(original_files_set) - if diff: - print(f'{BUILT_APPIUM_DIR_PATH} has {diff} files than {APPIUM_DIR_PATH}') - - sys.exit( - f"Python files in '{BUILT_APPIUM_DIR_PATH}' may differ from '{APPIUM_DIR_PATH}'. " - 'Please make sure setup.py is configured properly.' - ) - - def main(): print_current_version() new_version = get_new_version() - update_version_file(new_version) - - build() - assert_files_count_in_package() - ensure_publication(new_version) - commit_version_code(new_version) - build_sdist() - - tag_and_generate_changelog(new_version) - upload_sdist(new_version) - push_changes_to_master(new_version) if __name__ == '__main__': From 6922e042b26927b4ec71f6fb64065ea0bd1d9dee Mon Sep 17 00:00:00 2001 From: Kazuaki Matsuo Date: Thu, 14 Aug 2025 13:25:18 +0900 Subject: [PATCH 2/7] docs: update readme --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index a6dc3e3f..972c4e37 100644 --- a/README.md +++ b/README.md @@ -529,6 +529,8 @@ uv run pytest -n 2 test/functional/ios/search_context/find_by_ios_class_chain_te Follow the below steps. +Set `GH_TOKEN` env var to update the GitHub contents. + ```bash # Used to publish the package to pypi uv pip install twine From b1a70ae70217f101c19c60085672a2ab7533c917 Mon Sep 17 00:00:00 2001 From: Kazuaki Matsuo Date: Thu, 14 Aug 2025 13:28:33 +0900 Subject: [PATCH 3/7] remove unused modules from release.py --- script/release.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/script/release.py b/script/release.py index 88a37e31..8d0ac748 100644 --- a/script/release.py +++ b/script/release.py @@ -15,8 +15,6 @@ import glob import os -import shutil -import subprocess import sys from typing import List From 13dd9227d0e26d9d298f1c30fda7e528a7fbba68 Mon Sep 17 00:00:00 2001 From: Kazuaki Matsuo Date: Thu, 14 Aug 2025 13:30:52 +0900 Subject: [PATCH 4/7] cleanup more --- script/release.py | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/script/release.py b/script/release.py index 8d0ac748..a4202ea2 100644 --- a/script/release.py +++ b/script/release.py @@ -13,10 +13,8 @@ # limitations under the License. """Release script to publish release module to pipy.""" -import glob import os import sys -from typing import List CHANGELOG_PATH = os.path.join(os.path.dirname('__file__'), 'CHANGELOG.md') @@ -38,13 +36,6 @@ def get_new_version(): return line.rstrip() -VERSION_FORMAT = "version = '{}'\n" - - -def update_version_file(version): - call_bash_script(f'uv version {version}') - - def call_bash_script(cmd): if os.environ.get('DRY_RUN') is not None: print('{} Calls: {}'.format(MESSAGE_RED.format('[DRY_RUN]'), cmd)) @@ -67,18 +58,12 @@ def ensure_publication(new_version_num): if os.environ.get('DRY_RUN') is not None: print('Run with {} mode.'.format(MESSAGE_RED.format('[DRY_RUN]'))) - print('Are you sure to release as {}?[y/n]'.format(MESSAGE_YELLOW.format(new_version_num))) + print('Are you sure to publish a new built modules in dist directory as {}?[y/n]'.format(MESSAGE_YELLOW.format(new_version_num))) for line in sys.stdin: if line.rstrip().lower() == 'y': return sys.exit('Canceled release process.') -def get_py_files_in_dir(root_dir: str) -> List[str]: - return [ - file_path[len(root_dir) :] - for file_path in glob.glob(f'{root_dir}/**/*.py', recursive=True) + glob.glob(f'{root_dir}/**/*.typed', recursive=True) - ] - def main(): print_current_version() new_version = get_new_version() From 5e882aba1bff613fe512081a3fddca5d80284110 Mon Sep 17 00:00:00 2001 From: Kazuaki Matsuo Date: Thu, 14 Aug 2025 13:31:41 +0900 Subject: [PATCH 5/7] cleanup more --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index 972c4e37..b2044fda 100644 --- a/README.md +++ b/README.md @@ -540,9 +540,7 @@ rm -rf dist uv run semantic-release version --patch|--minor|--major # this 'release' script now has pushing built modules to pypi only. -./release.sh # release - -# input the same version +./release.sh # and type the target version. ``` If the `pypi` was not able to publish with user name and password, please try out `-u` and `-p` option by yourself with `twine` such as `twine upload -u -p dist/Appium-Python-Client-4.1.0.tar.gz`. From 32602d963d1178aacb552b49ba831db42c516b23 Mon Sep 17 00:00:00 2001 From: Kazuaki Matsuo Date: Thu, 14 Aug 2025 13:32:58 +0900 Subject: [PATCH 6/7] simplify --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b2044fda..248c4f45 100644 --- a/README.md +++ b/README.md @@ -537,7 +537,7 @@ uv pip install twine rm -rf dist # bumping the version, building a package and creating a tag. -uv run semantic-release version --patch|--minor|--major +uv run semantic-release version # this 'release' script now has pushing built modules to pypi only. ./release.sh # and type the target version. From 04b6154d16ab71f8d2087601ead76751fe9d94d6 Mon Sep 17 00:00:00 2001 From: Kazuaki Matsuo Date: Thu, 14 Aug 2025 13:34:38 +0900 Subject: [PATCH 7/7] reformat with ruff --- script/release.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/script/release.py b/script/release.py index a4202ea2..1c3eeaf9 100644 --- a/script/release.py +++ b/script/release.py @@ -42,6 +42,7 @@ def call_bash_script(cmd): else: os.system(cmd) + def upload_sdist(new_version_num): wheel_file = 'dist/appium_python_client-{}-py3-none-any.whl'.format(new_version_num) push_file = 'dist/appium_python_client-{}.tar.gz'.format(new_version_num) @@ -54,16 +55,22 @@ def upload_sdist(new_version_num): ) ) + def ensure_publication(new_version_num): if os.environ.get('DRY_RUN') is not None: print('Run with {} mode.'.format(MESSAGE_RED.format('[DRY_RUN]'))) - print('Are you sure to publish a new built modules in dist directory as {}?[y/n]'.format(MESSAGE_YELLOW.format(new_version_num))) + print( + 'Are you sure to publish a new built modules in dist directory as {}?[y/n]'.format( + MESSAGE_YELLOW.format(new_version_num) + ) + ) for line in sys.stdin: if line.rstrip().lower() == 'y': return sys.exit('Canceled release process.') + def main(): print_current_version() new_version = get_new_version()