Skip to content

Commit ff68b03

Browse files
committed
chore: use semantic-release for most of release script execution
1 parent 04a8580 commit ff68b03

File tree

4 files changed

+19
-72
lines changed

4 files changed

+19
-72
lines changed

CHANGELOG.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
# CHANGELOG
22

3+
<!-- version list -->
34

45
## Unreleased
56

67
### Chores
78

8-
- Add python-semantic-release as the deps
9-
([`0a2ffad`](https://github.com/appium/python-client/commit/0a2ffad9f3fb37f7ef5ef6632514f07e1fc97359))
9+
- Revert version created by release script checking
10+
([#1164](https://github.com/appium/python-client/pull/1164),
11+
[`04a8580`](https://github.com/appium/python-client/commit/04a8580f999843bc9d121c1ed4ce872761350f31))
12+
13+
- Use semantic release changelog instead of gitchangelog
14+
([#1163](https://github.com/appium/python-client/pull/1163),
15+
[`dd3709e`](https://github.com/appium/python-client/commit/dd3709e084e802d6534d51151be1bd45456a4ebd))
1016

1117
### Documentation
1218

README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -530,12 +530,17 @@ uv run pytest -n 2 test/functional/ios/search_context/find_by_ios_class_chain_te
530530
Follow the below steps.
531531
532532
```bash
533-
uv pip install setuptools
533+
# Used to publish the package to pypi
534534
uv pip install twine
535-
# Type the new version number and 'yes' if you can publish it
536-
# You can test the command with DRY_RUN
537-
DRY_RUN=1 ./release.sh
535+
536+
rm -rf dist
537+
# bumping the version, building a package and creating a tag.
538+
uv run semantic-release version --patch|--minor|--major
539+
540+
# this 'release' script now has pushing built modules to pypi only.
538541
./release.sh # release
542+
543+
# input the same version
539544
```
540545
541546
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 <name> -p <pass> dist/Appium-Python-Client-4.1.0.tar.gz`.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ prerelease = false
102102
[tool.semantic_release.changelog]
103103
exclude_commit_patterns = []
104104
mode = "update"
105-
insertion_flag = "=========\nCHANGELOG\n========="
105+
insertion_flag = "<!-- version list -->"
106106
template_dir = "templates"
107107

108108
[tool.semantic_release.changelog.default_templates]

script/release.py

Lines changed: 1 addition & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def print_current_version():
3535

3636

3737
def get_new_version():
38-
print(MESSAGE_GREEN.format('new version:'))
38+
print(MESSAGE_GREEN.format('Pushing version:'))
3939
for line in sys.stdin:
4040
return line.rstrip()
4141

@@ -53,17 +53,6 @@ def call_bash_script(cmd):
5353
else:
5454
os.system(cmd)
5555

56-
57-
def commit_version_code(new_version_num):
58-
call_bash_script('git commit pyproject.toml uv.lock -m "Bump {}"'.format(new_version_num))
59-
60-
61-
def tag_and_generate_changelog(new_version_num):
62-
call_bash_script('git tag "v{}"'.format(new_version_num))
63-
call_bash_script('uv run semantic-release changelog')
64-
call_bash_script('git commit {} -m "Update changelog for {}"'.format(CHANGELOG_PATH, new_version_num))
65-
66-
6756
def upload_sdist(new_version_num):
6857
wheel_file = 'dist/appium_python_client-{}-py3-none-any.whl'.format(new_version_num)
6958
push_file = 'dist/appium_python_client-{}.tar.gz'.format(new_version_num)
@@ -76,12 +65,6 @@ def upload_sdist(new_version_num):
7665
)
7766
)
7867

79-
80-
def push_changes_to_master(new_version_num):
81-
call_bash_script('git push origin master')
82-
call_bash_script('git push origin "v{}"'.format(new_version_num))
83-
84-
8568
def ensure_publication(new_version_num):
8669
if os.environ.get('DRY_RUN') is not None:
8770
print('Run with {} mode.'.format(MESSAGE_RED.format('[DRY_RUN]')))
@@ -92,66 +75,19 @@ def ensure_publication(new_version_num):
9275
return
9376
sys.exit('Canceled release process.')
9477

95-
96-
def build_sdist():
97-
call_bash_script('uv build')
98-
99-
100-
def build() -> None:
101-
shutil.rmtree(BUILT_APPIUM_DIR_PATH, ignore_errors=True)
102-
status, output = subprocess.getstatusoutput('uv run python setup.py install')
103-
if status != 0:
104-
sys.exit(f'Failed to build the package:\n{output}')
105-
106-
10778
def get_py_files_in_dir(root_dir: str) -> List[str]:
10879
return [
10980
file_path[len(root_dir) :]
11081
for file_path in glob.glob(f'{root_dir}/**/*.py', recursive=True) + glob.glob(f'{root_dir}/**/*.typed', recursive=True)
11182
]
11283

113-
114-
def assert_files_count_in_package() -> None:
115-
original_files = get_py_files_in_dir(APPIUM_DIR_PATH)
116-
built_files = get_py_files_in_dir(BUILT_APPIUM_DIR_PATH)
117-
118-
if len(original_files) != len(built_files):
119-
print(f"The count of files in '{APPIUM_DIR_PATH}' and '{BUILT_APPIUM_DIR_PATH}' were different.")
120-
121-
original_files_set = set(original_files)
122-
built_files_set = set(built_files)
123-
124-
diff = original_files_set.difference(built_files_set)
125-
if diff:
126-
print(f"'{APPIUM_DIR_PATH}' has '{diff}' files than {BUILT_APPIUM_DIR_PATH}")
127-
diff = built_files_set.difference(original_files_set)
128-
if diff:
129-
print(f'{BUILT_APPIUM_DIR_PATH} has {diff} files than {APPIUM_DIR_PATH}')
130-
131-
sys.exit(
132-
f"Python files in '{BUILT_APPIUM_DIR_PATH}' may differ from '{APPIUM_DIR_PATH}'. "
133-
'Please make sure setup.py is configured properly.'
134-
)
135-
136-
13784
def main():
13885
print_current_version()
13986
new_version = get_new_version()
14087

141-
update_version_file(new_version)
142-
143-
build()
144-
assert_files_count_in_package()
145-
14688
ensure_publication(new_version)
14789

148-
commit_version_code(new_version)
149-
build_sdist()
150-
151-
tag_and_generate_changelog(new_version)
152-
15390
upload_sdist(new_version)
154-
push_changes_to_master(new_version)
15591

15692

15793
if __name__ == '__main__':

0 commit comments

Comments
 (0)